SQL is a database language that has commands to create, manipulate etc the database. All the commands can be broadly classified into following categories:
- DDL Commands
- DML Commands
- DCL Commands
- TCL Commands
DDL(Data Definition Language) Commands:
Data Definition Language commands in SQL are used to define the database schema. These commands deal with description of database schema and is also used to modify the structure of database objects
Examples of DDL Commands:
- CREATE – Create command is used to create the database or objects like View, Function, Procedures etc.
- DROP – DROP command is used to delete objects from the database.
- ALTER– ALTER command is used to alter the structure of the database.
- TRUNCATE– TRUNCATE command is used to remove records from table along with their memory spaces.
- COMMENTS– COMMENTS command is used to add comments to data dictionary.
- RENAME – RENAME command is used to rename the object in the database.
DML(Data Manipulation Language) Commands:
Data Manipulation Commands are used to manipulate the data present in the database.
Example of DML Commands:
- SELECT – SELECT command is used to retrieve data from database.
- INSERT – INSERT command is used to insert data in a table.
- UPDATE – UPDATE command is used to change data in a table.
- DELETE– DELETE command is useful in deleting records from table in database.
DCL(Data Control Language) Commands:
Data Control Language Commands deals with rights, permissions, controls of a database system
Example of DCL Commands:
- GRANT – GRANT command gives user access privileges to database.
- REVOKE – REVOKE command withdraw user access privileges given using GRANT command.
TCL(Transaction Control Language) Commands:
Transaction Control Language Commands are used to deal with transactions in the database
Example of TCL Commands:
- COMMIT – COMMIT command commits a transaction.
- ROLLBACK – ROLLBACK command rollbacks a transaction if any error occurs.
- SAVEPOINT – SAVEPOINT command sets a Save point in the transaction.
- SET TRANSACTION – SET TRANSACTION command is used to specify characteristics for the transaction.