SQL commands:
SQL commands are the instructions, given to a database to perofrm some functions and tasks there are also called queries, these commands or rather queries can be used to search the database and can perform functions like creation, updation, delete, replace operations.
SQL commands are divided into four categories :
DDL – Data Definition Language
DQL – Data Query language
DML – Data Manipulation Language
DCL – Data Control Language
TCL – Transaction Control Langauge
1. DDL(Data Definition Language): DDL or Data Definition Language consists of the SQL commands which are wont to define the database schema. It describes the database schema and is employed to make and modify the structure of database objects within the database.
Examples :
CREATE – is employed to make the database or its objects (like table, index, function, views, store procedure and triggers).
DROP– is employed to delete objects from the database.
ALTER – is employed to change the structure of the database.
TRUNCATE – is employed to get rid of all records from a table, including all spaces allocated for the records are removed.
COMMENT – is employed to feature comments to the info dictionary.
RENAME – is employed to rename an object existing within the database.
2.DQL (Data Query Language): DML statements are used for firing queries on the info within schema objects. the aim of DQL Command is to urge some schema relation supported the query passed thereto .
Example :
SELECT – is employed to retrieve data from a database.
3. DML(Data Manipulation Language): The SQL commands that manipulate the info present within the database belongs to DML or Data Manipulation Language and this includes most of the SQL statements.
Examples :
INSERT – is employed to insert data into a table.
UPDATE – is employed to update existing data within a table.
DELETE – is employed to delete records from a database table.
4. DCL(Data Control Language): DCL includes commands like GRANT and REVOKE which mainly deals with the rights, permissions, and other controls of the database system.
Examples :
GRANT – gives user’s access privileges to the database.
REVOKE – withdraw user’s access privileges given by using the GRANT command.
5. TCL(transaction Control Language): TCL commands are said to the transaction within the database.
Examples :
COMMIT – commits a transaction.
ROLLBACK – rollbacks a transaction just in case of any error occurs.
SAVEPOINT – sets a savepoint within a transaction.
SET TRANSACTION – specifies characteristics for the transaction.