---
tags: Other
---
# DDL, DQL, DML, DCL, TCL

## DDL (Data Definition Language)
資料定義語言,是 SQL 語言集中負責資料結構定義與資料庫物件定義的語言。
It simply deals with descriptions of the database schema and is used to create and modify the structure of database objects in the database.
- `CREATE` – is used to create the database or its objects (like table, index, function, views, store procedure and triggers).
- `DROP` – is used to delete objects from the database.
- `ALTER` – is used to alter the structure of the database.
- `TRUNCATE` – is used 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.
## DQL (Data Query Language)
資料查詢語言,用來查詢資料表裡的資料。
- `SELECT` – is used to retrieve data from the a database.
## DML (Data Manipulation Language)
資料操作語言,用來處理資料表裡的資料。
- `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.
## DCL (Data Control Language)
資料控制語言,用來控制資料表、檢視表之存取權限,提供資料庫的安全性。
- `GRANT` – gives user’s access privileges to database. 賦予使用者使用權限
- `REVOKE` – withdraw user’s access privileges given by using the GRANT command. 取消使用者的使用權限
## TCL (Transaction Control Language)
事務控制語言,存檔點。
- `COMMIT` – commits a Transaction.
- `ROLLBACK` – rollbacks a transaction in case of any error occurs.
- `SAVEPOINT` – sets a savepoint within a transaction.
- `SET TRANSACTION` – specify characteristics for the transaction.
## 參考資料
- [SQL | DDL, DQL, DML, DCL and TCL Commands / GeeksforGeeks](https://www.geeksforgeeks.org/sql-ddl-dql-dml-dcl-tcl-commands/)