There are mainly five topics that include various commands:
1. DDL: Data Definition Language
i) Create Command: If the programmer wants to create a table, this command is used.
Syntax: Create table table_name
{
Column_1 datatype;
Column_2 datatype;
…
Column_n datatype;
};
ii) Drop Command: If the programmer wants to delete the table inclusive of the contents of the table, then this command is used
Syntax: droptable table_name;
iii) Alter Command: If a programmer wants to alter the contents of the table such as adding or deleting the columns or rows, this command is used.
Syntax: altertable table_name
{
Add new_column_1 datatype;
Add new_column_2 datatype;
}
iv) Rename Command: When the programmer wants to change or alter the table's name, this command is used.
Syntax: renametable old table_name;
To new_table_name;
v) Truncate: When the programmer wants to delete the table contents without affecting the table structure, this command is used.
Syntax: Truncate table table_name;
2. DML: Data Manipulation Language
i) Insert Command: When the programmers want to insert a set of values into the table's structure, this command is used.
Syntax: Insert into table_name(column_1_name, column_2_name,…) values(value_1, value_2..)
ii)Select Command: When the programmer wants to select a piece of information from the structure of the table, then this command is utilized. It is one of the essential commands in SQL. However, there are many formats depending on the requirement type. Everyone should note that while using this command, the table contents must be full and not empty.
The syntax for displaying the information in the table:
Select * table_name;
iii)Update Command: When the programmer wants to update some information into an existing table, then this command is used
Syntax: Update table_name set;
Column_name1=value1, Column2_name1=value2;
. . . . .
Where condition;
iv) Delete Command: This command is used when the programmer wants to delete any content from the table or data from the table.
Syntax: Delete from table_name where condition;
3. DCL – Data Control Language:
When the programmer wants to grant or withdraw access or authorization from any database user, these commands are used. There are two commands:
i) Grant Command: When a programmer wants to provide access to a database user, this command is used.
Syntax: Grant Select, Update on my_table to user_1, user_2;
ii) Revoke Command: This command is used whenever a programmer wants to withdraw access from the user.
Syntax: Revoke Select, Update on my_table to user_1, user_2;
4. TCL – Transactional Control Language:
These are the commands that are already present in the database. This is why they are always used only with DML Commands such as Insert, delete, and update commands.
i) Commit Command: It saves all the transactions in the database.
ii) Rollback Command: This command is used to revert the transactions that are not saved in the database.
iii) Save point Command: Without rolling back to the entire transaction, this command is used to roll back to a specific transaction only.
5. DCL - Data Query Language:
It is only used to retrieve the data from the databases.
i) Select Command: This command selects the attribute depending on the condition defined by the ‘where’ clause.