0% found this document useful (0 votes)
7 views4 pages

Complete SQL Guide

This document is a comprehensive SQL (MySQL) learning guide covering SQL basics, table creation, data types, and CRUD operations. It includes examples and logical questions to enhance understanding of SQL concepts. The guide serves as a resource for creating databases, storing, retrieving, and modifying data effectively.

Uploaded by

naveenna242
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Complete SQL Guide

This document is a comprehensive SQL (MySQL) learning guide covering SQL basics, table creation, data types, and CRUD operations. It includes examples and logical questions to enhance understanding of SQL concepts. The guide serves as a resource for creating databases, storing, retrieving, and modifying data effectively.

Uploaded by

naveenna242
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Complete SQL (MySQL) Learning Guide

1. SQL Basics

SQL (Structured Query Language) is used to communicate with databases. Properties: •


Case-insensitive • Declarative language • Works on relational databases Way of Use: • Creating
databases • Storing data • Retrieving data • Modifying data

10 Examples

SHOW DATABASES;

CREATE DATABASE company;

USE company;

DROP DATABASE test;

SHOW TABLES;

DESCRIBE employees;

SELECT DATABASE();

CREATE DATABASE school;

USE school;

SHOW TABLES;

10 Logical Questions

• What is SQL?

• What is a database?

• Difference between SQL and MySQL?

• What is a table?

• What is a row?

• What is a column?

• What does USE do?

• Can SQL run without DB?

• Is SQL case sensitive?


• Why SQL is important?
2. CREATE TABLE & DATA TYPES

Properties: • Defines table structure • Uses data types • Supports constraints Way of Use: • Design
database schema

10 Examples

CREATE TABLE users(id INT, name VARCHAR(50));

CREATE TABLE students(id INT, age INT);

CREATE TABLE books(price DECIMAL(10,2));

CREATE TABLE orders(date DATE);

CREATE TABLE login(email VARCHAR(100));

CREATE TABLE products(stock INT);

CREATE TABLE admin(role VARCHAR(20));

CREATE TABLE marks(score INT);

CREATE TABLE city(name VARCHAR(30));

CREATE TABLE employee(salary DECIMAL(8,2));

10 Logical Questions

• What is INT?

• What is VARCHAR?

• When to use DECIMAL?

• What is DATE type?

• Why choose data types?

• Max size of VARCHAR?

• Difference INT vs BIGINT?

• What is TEXT?

• Can NULL be stored?

• Why schema matters?


3. CRUD Operations

CRUD = Create, Read, Update, Delete Properties: • Core SQL usage • Used in all applications

10 Examples

INSERT INTO users VALUES(1,'A');

INSERT INTO users(name) VALUES('B');

SELECT * FROM users;

SELECT name FROM users;

UPDATE users SET name='C' WHERE id=1;

DELETE FROM users WHERE id=1;

SELECT COUNT(*) FROM users;

SELECT * FROM users WHERE id=2;

UPDATE users SET name='D';

DELETE FROM users;

10 Logical Questions

• What is CRUD?

• Which command reads data?

• What is WHERE?

• Can UPDATE run without WHERE?

• What happens if DELETE has no WHERE?

• What is COUNT?

• Difference INSERT vs UPDATE?

• Can SELECT filter columns?

• Is DELETE reversible?

• What is best practice for DELETE?

You might also like