When I watched the database video, I once talked about the content of the SQL language. I sorted it out below
Standard SQL contains nine statements.
Data Query |
Select |
Data Definition |
Create, drop, alter |
Data manipulation |
Insert, update, delete |
Data Control |
Grant, revoke |
The SQL language can be divided into four categories:
Category |
Function |
Example |
Data Definition Language (DDL) |
Defines the data structure and creates, modifies, and deletes database objects. |
Create Table: Create a database table Drop index: Delete the table index. Alter table: Add a table column, redefine the table column, and change the storage allocation. |
Data manipulation language (DML) |
Allows you to insert or update data in the database. |
Insert: add data rows to the table Select: Retrieves data rows. Delete: delete data rows. Update: Change Data |
Data Control Language (DCL) |
Used to specify various permissions of database users |
GRANT: grant permissions or roles to users or other roles Revoke: revoke permissions from a user or database role |
Database Transaction Control Language |
To ensure database integrity |
Commit work: Write the changes made by the current firm to the disk. Rollback: invalidate all changes since the last submission |
In addition, pay special attention to code specifications when writing SQL statements.
Basic SQL statement Syntax:
1. Each statement must end with a semicolon.
2. Free writing. You can use SQL statements to write a single row (long rows are not recommended) or separate them into several rows.
3. It is case-insensitive. keywords, table names, and column names can be case-insensitive, but the content of columns is case-sensitive.