SQL is a database language that has SQL commands to create, manipulate etc the database. All the SQL 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 the description of database schema and are also useful in modifying the structure of database objects
Examples of DDL Commands:
- CREATE – Create command is useful in creating the database or objects like View, Function, Procedures etc
- DROP – DROP command is useful in deleting objects from the database
- ALTER- ALTER command is useful for altering the structure of the database
- TRUNCATE- TRUNCATE command is useful in removing records from the table along with their memory spaces
- COMMENTS- COMMENTS command is useful for adding comments to data dictionary name
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 useful in retrieving data from the database
- INSERT – INSERT command is useful in inserting data into a table
- UPDATE – UPDATE command is useful to changing data in a table
- DELETE- DELETE command is useful in deleting records from the table in a 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 a database
- REVOKE – REVOKE command withdraw user access privileges given using GRANT command
TCL(Transaction Control Language) Commands:
Transaction Control Language Commands are useful in dealing with transactions in the database
Example of TCL Commands:
- ROLLBACK – ROLLBACK command rollbacks a transaction if any error occursSAVEPOINT
- SET TRANSACTION – SET TRANSACTION command is useful in specifying characteristics for the transaction