(3) SQL language

1. SQL language

The picture is transferred from Baizhan Programmer

1. Introduction to SQL language

Structured Query Language (Structured Query Language) referred to as SQL (pronunciation: sequal['si:kwəl]), is a database query and programming language for accessing data and querying, updating and managing relational database systems.

2. What can SQL do?

  • SQL Executes queries against the database
  • SQL can insert new records in the database
  • SQL to update data in the database
  • SQL to delete records from database
  • SQL to create a new database
  • SQL can create new tables in the database
  • SQL can create stored procedures in the database
  • SQL can create views in the database
  • SQL can set permissions on tables, stored procedures and views

3. SQL Standard

SQL is an American standard for database languages ​​adopted by the American National Institute of Standards (ANSI) in October 1986, and then the International Organization for Standardization (ISO) promulgated SQL as a formal international standard. In April 1989, ISO proposed the SQL89 standard with integrity features. In November 1992, it announced the SQL92 standard. In this standard, the database is divided into three levels: basic set, standard set and complete set. In 1999, the 99 version of the standard was released. The latest version is SQL2016. Several representative versions: SQL86, SQL92, SQL99.

Two, SQL language classification

  1. Data Query Language (DQL: Data Query Language) Its statement, also known as "data retrieval statement", is used to obtain data from the table and determine how the data is given in the application program . The keyword SELECT is the most used verb in DQL (and all SQL).

    • SELECT
    • FROM
    • WHERE
    • ORDER BY
    • HAVING
  2. Data Manipulation Language (DML: Data Manipulation Language) statements include verbs INSERT, UPDATE and DELETE. They are used to add, modify and delete rows in the table respectively .

    • INSERT: add data
    • UPDATE: update data
    • DELETE: delete data
  3. Data Definition Language (DDL: Data Definition Language) defines the database object language, and its statements include verbs CREATE and DROP.

    • CREATE: create database objects
    • ALTER: modify database objects
    • DROP: delete database objects
  4. Data Control Language (DCL: Data Control Language) Its statements obtain permission through GRANT or REVOKE to determine the user's access to database objects .

    • GRANT: grant a user some kind of permission
    • REVOKE: Recycle a certain permission granted
  5. Transaction Control Language (TCL: Transaction Control Language) Its statements can ensure that all rows of the table affected by the DML statement are updated in a timely manner .

    • COMMIT: Commit the transaction
    • ROLLBACK: rollback transaction
    • SAVEPOINT: set rollback point

Notice:


The data manipulation language DML (insert, update, delete) is aimed at the data in the table ;

The data definition language DDL (create, alter, drop) is aimed at database objects , such as database database, table table, index index, view view, stored procedure procedure, trigger trigger;

3. SQL language syntax

  1. SQL statements are not case-sensitive, and keywords are suggested to be capitalized .
  2. SQL statements can be written in one or more lines and end with a semicolon .

 

おすすめ

転載: blog.csdn.net/m0_62735081/article/details/126652961