Loading...
Loading...
00:00:00

SQL Commands

SQL (Structured Query Language) commands are used to interact with relational databases, such as inserting data, retrieving data, updating data, deleting data, creating tables, and modifying tables.

SQL commands can be classified into four main categories: Data Manipulation Language (DML), Data Definition Language (DDL), Data Control Language (DCL), and Transaction Control Language (TCL).

  1. Data Manipulation Language (DML) commands are used to manipulate data in a database. These commands include SELECT, INSERT, UPDATE, and DELETE.

  2. Data Definition Language (DDL) commands are used to define or modify the structure of a database. These commands include CREATE, ALTER, and DROP.

  3. Data Control Language (DCL) commands are used to control the access to a database. These commands include GRANT and REVOKE.

  4. Transaction Control Language (TCL) commands are used to control transactions in a database. These commands include COMMIT, ROLLBACK, and SAVEPOINT.

Uses of  SQL Commands

The SELECT command is used to retrieve data from a database, while the INSERT command is used to add new data to a database. The UPDATE command is used to modify existing data, and the DELETE command is used to remove data from a database.

The CREATE command is used to create new tables or other database objects, while the ALTER command is used to modify the structure of existing tables. The DROP command is used to delete tables or other database objects.

The GRANT command is used to grant permissions to users or roles, while the REVOKE command is used to revoke permissions. The COMMIT command is used to save changes to a database, while the ROLLBACK command is used to undo changes. The SAVEPOINT command is used to create a restore point in a transaction.

In summary, SQL commands are used to interact with relational databases, and they can be classified into four categories: DML, DDL, DCL, and TCL. These commands allow developers to manipulate data, define the structure of a database, control access to a database, and manage transactions.