Hey all, Welcome to Geeksforjobs
Structured Query Language(SQL) as we all know is the database language by the use of which we can perform certain operations on the existing database and also we can use this language to create a database. SQL uses certain commands like Create, Drop, Insert, etc. to carry out the required tasks.These SQL commands are mainly categorized into four categories as discussed below:
Data Definition Language
DDL or Data Definition Language actually consists of the SQL commands that can be used to define the database schema. It deals with descriptions of the database schema and is used to create and modify the structure of database objects in the database. Data definition language is used to store the information like the number of tables and schemas, their names, indexes, columns in each table, constraints, etc. Some of the examples of DDL commands are-
- CREATE – This command allows creating the database or its objects (like a table, index, function, views, store procedure, and triggers).
- DROP –This command allows us to delete objects from the database.
- ALTER-This command allows altering the structure of the database.
- TRUNCATE–This command allows us to remove all records from a table, including all spaces allocated for the records are removed.
- COMMENT –is used to add comments to the data dictionary.
- RENAME –is used to rename an object existing in the database.
Data Manipulation Language
It handles user requests.These commands are used for manipulating the data in database.Some of the examples of DML commands are:
- SELECT – is used to retrieve data from the a database.
- INSERT – is used to insert data into a table.
- UPDATE – is used to update existing data within a table.
- DELETE – is used to delete records from a database table.
Data Control Language
DCL includes commands such as GRANT and REVOKE which mainly deals with the rights, permissions, and other controls of the database system. It is used to retrieve the stored or saved data. Examples of DCL commands:
- GRANT-gives user’s access privileges to the database.
- REVOKE-withdraw user’s access privileges given by using the GRANT command.
Transaction Control Language
TCL commands deal with the transaction within the database.They are also used to make the changes that are done by DML statements. Examples of TCL commands:
- COMMIT– commits a Transaction.
- ROLLBACK– rollbacks a transaction in case any error occurs.
- SET TRANSACTION–specify characteristics for the transaction.
- SAVEPOINT–sets a savepoint within a transaction.
SQL stands for the Structured Query Language. SQL is a standard query language used for maintaining the relational database and perform many different operations of data manipulation on the data.
It is used as a commanding (Query) language to access databases.
An index is used to increase the performance and allow faster retrieval of records from the table.