Types of SQL Statements - Karan Rajpoot
Types of SQL Statements
The SQL statement can be categorized into the following four ways: -
1) DDL ( Data Definition Language)
2) DML ( Data Manipulation language)
3) DCL ( Data Control Language)
4) TCL ( Transaction Control Language)
Now we will understand each of the above statements with examples: -
a) CREATE: - It is used to create objects in the database.
Example: -
b) ALTER: - It is used to alter the structure of the database.
Example: -
c) RENAME: - To rename an object.
Example: -
d) DROP: - This command is used to delete the objects from the database.
Example: -
a) SELECT: - It is used to retrieve the data from the database.
Example: -
b) INSERT: - This command is used to insert the data into a table.
Example: -
c) UPDATE: - This command is used to update the existing records within the table.
Example: -
a) COMMIT: -
b) ROLLBACK: -
Thank You!!
The SQL statement can be categorized into the following four ways: -
1) DDL ( Data Definition Language)
2) DML ( Data Manipulation language)
3) DCL ( Data Control Language)
4) TCL ( Transaction Control Language)
Now we will understand each of the above statements with examples: -
1) DDL ( Data Definition Language): -
The DDL statement provides commands for defining relation schemas, that is for creating tables, indexes, sequences and so on and also commands for dropping, altering renaming objects.a) CREATE: - It is used to create objects in the database.
Example: -
Object Creation |
Example: -
Alter the structure of the database |
Example: -
Rename of a tablespace |
d) DROP: - This command is used to delete the objects from the database.
Example: -
Drop object from the database |
2) DML (Data Manipulation Language): -
The DML statements are used to alter or modification of the database. The databases are managed with the help of below statements.
a) SELECT: - It is used to retrieve the data from the database.
Example: -
Retrieve the data from the database |
Example: -
Insert data into a table |
Example: -
Updated the existing record |
3) DCL (Data Control language): -
The DCL statements are used to Grant the permission from the user or to revoke the already given permission from the user.
a) GRANT: - This command is used to give the permission of the user.
Example: -
Grant Permission |
b) Revoke: - This command is used to revoke the already given permission from the user.
Example: -
Revoke Permission |
4) TCL (Transaction Control Language): -
The TCL statement is used to commit the transaction after work done and restore the database to its original stage since the last commit.
a) COMMIT: -
Commit the transaction |
Rollback the transaction |