SQL Short Notes
SQL Short Notes
SHORT NOTES
www.campusmonk.io
01
WHAT IS SQL?
• sql is stand for structured query language.
• This database language is mainly designed for maintaining the data in
relational database management systems.
• sql is standard language for accessing and manipulating database.
1. CREATE :
This command is used to create a new database or table. Syntax:
3. DELETE :
The DELETE statement is used to delete the existing records in a table.
Syntax: DELETE FROM table_name[WHERE condition]; Example: DELETE
Customers WHERE CuntomerName = "iamrupnath"; );
04
4. TRUNCATE:
A truncate SQL statement is used to remove all rows (complete data)
from a table. It is similar to the DELETE statement with no WHERE clause.
Syntax:
TRUNCATE TABLE table_name;
Example:
TRUNCATE TABLE Employee;
DML COMMANDS:
1.INSERT:
SQL INSERT statement is a SQL query. It is used to insert a single or a multiple records
in a table.
Syntax:
INSERT INTO table_name
VALUES (value1, value2, value3 .....);
Example:
INSERT INTO STUDENTS (ROLL_NO, NAME, AGE, CITY)
VALUES (1, iamrupnath, 21, Kolkata)
05
3. ALTER:
The ALTER TABLE statement in Structured Query Language allows you to add,
modify, and delete columns of an existing table.
Syntax:
ALTER table_name
ADD column_name datatype;
Example:
ALTER TABLE EMPLOYEE
ADD Email varchar (255);
4. DROP:
The DROP TABLE statement is used to drop an existing table in a database. This
command deletes both the structure & Records Stored in the table. Syntax:
4. DROP:
The DROP TABLE statement is used to drop an existing table in a database. This
command deletes both the structure & Records Stored in the table. Syntax:
1. COMMIT :
Commits a Transaction. The COMMIT command saves all the transactions to
the database since the last COMMIT or ROLLBAC command.
Syntax: COMMIT;
Example:
DELETE FROM Student WHERE AGE = 21;
COMMIT:
2. ROLLBACK:
If any error occurs with any of the SQL-grouped statements, all changes
ROLLBACK;
08
DCL COMMANDS:
1. GRANT:
It is used to give user access privileges to a database.
Syntax:
GRANT SELECT, UPDATE ON MY TABLE TO SOME_USER, ANOTHER_USER;
2. REVOKE:
GRANT SELECT, UPDATE ON MY TABLE TO SOME_USER< ANOTHER_USER;