DEV Community

Cover image for A must-have for database entry, a complete collection of SQL statements
tom
tom

Posted on

A must-have for database entry, a complete collection of SQL statements

Data Definition Language (DDL)
DDL is used to define and modify database structures.

CREATE DATABASE: Create a new database.
DROP DATABASE: Delete a database.
CREATE TABLE: Create a new table.
ALTER TABLE: Modify the table structure, such as adding, deleting, or modifying columns.
DROP TABLE: Delete a table.
CREATE INDEX: Create an index to improve query efficiency.
DROP INDEX: Deletes an index.
Data Manipulation Language DML
DML is used to add, delete, and modify data in the database.

INSERT INTO: Inserts new data into a table.
UPDATE: Update the data in the table.
DELETE: Delete data from the table.
Data Query Language DQL
DQL is mainly used to query data in the database.

SELECT: Select data from the database. It can be used with various clauses, such as WHERE condition filtering, ORDER BY sorting, GROUP BY grouping, and so on.
JOIN: Combines rows from two or more tables based on common fields between these tables.
Data Control Language DCL
DCL is used to define the access permissions and security levels for databases, tables, and fields.

GRANT: Grant user permissions.
REVOKE: Recover user permissions.
transaction control statement
BEGIN TRANSACTION or START TRANSACTION: Start a transaction.
COMMIT: Submits the current transaction, making all changes since BEGIN TRANSACTION permanent.
ROLLBACK: Roll back the current transaction, canceling all changes since BEGIN TRANSACTION.

Top comments (0)