SQL (Structured Query Language) is a relational database management system (RDBMS) designed for applications with client/server architecture. The terms client, server, and client/server can be used to refer to very general concepts or specific terms of hardware or software.
In general, there are 3 (three) types of SQL commands that SQL can use, namely: DDL (Data Definition Language), DML (Data Manipulation Language), and DCL (Data Control Language). The following is an explanation and a list of each of these SQL commands:
-
DDL or Data Definition Language
DDL is a SQL command related to defining a database structure, in this case databases and tables. Some of the basic commands included in this DDL include:
- CREATE : As the name suggests, the create command is used to create something, in this case a database and a table.
- ALTER : The alter command is used to change the structure or change information. The alter command can be used for databases or tables.
- RENAME : The rename command is usually used to rename a table, if a table is to be renamed.
- DROP : The drop command is used to delete, so if you use this command you have to be careful because drop can access databases, tables, columns, indexes, procedures and others.
-
DML or Data Manipulation Language
DML is a SQL command that deals with the manipulation or processing of data or records in tables. SQL commands included in the DML include:
- SELECT : The select command is used to display data in a table in a database.
- INSERT : Insert command is used to add data to a table in the database.
- UPDATE : Update is used to change data, or modify data contained in a table.
- DELETE : The delete command is used to delete data or records in a table.
-
DCL or Data Control Language
DCL is a SQL command related to user manipulation and privileges. SQL commands included in the DCL include:
- GRANT : The grant command is used to grant access rights or permissions to the user in the database to be able to access the database. In addition, the grant command can also be used to add new users or users in the DBMS.
- REVOKE : The revoke command is the opposite of the grant command, the revoke command is used to remove or revoke permissions.
The following are some of the uses of SQL including:
- SQL allows you to access and manipulate databases.
- SQL can execute queries against database
- SQL can fetch data from database
- SQL can insert records in database
- SQL can update records in database
- SQL can delete records from database
- SQL can create new database
- SQL can create new tables in database
- SQL can create database stored procedures
- SQL can create views in database
- SQL can set permissions on tables, procedures, and views