What is SQL (Structured Query Language)?
Structured Query Language (Structured Query Language) for short, SQL, is a special purpose programming language, a database query and programming language, used to access data and query, update, and manage relational database systems.
- The SQL language was proposed by Boyce and Chamberlin in 1974 and was first developed by IBM
- In the early 1970s,
- SQL has data definition, data manipulation and data control. [3]
- Structured query language consists of 6 parts:
- 1. Data query language (
Structured query language data definition
- In the implementation of a relational database, the first step is to establish a relational schema, defining the structure of the basic table, that is, which attributes the relational schema is composed of, the data type of each attribute and the possible length of the data, whether to allow null values and other Integrity constraints. [6]
- Define the basic table:
- CREATE TABLE <table name> (<column name 1> <data type> [column-level integrity constraint]
- [, <Column name 2> <data type> [column-level integrity constraints]] ...
- [, <-Column name n> <data type> [column-level integrity constraint]]
- [, List-level integrity constraints]]; [6]
- Explanation:
- <> is the part that must be defined in the SQL statement, and [] is the optional part of the SQL statement, which can be omitted. [6]
- CREATE TABLE indicates that it is a SQL keyword, indicating the function of this SQL statement. [6]
- <table name> is the name of the basic table to be defined. A table can be composed of one or several attributes (columns), but there is at least one attribute. A table without all attributes is not allowed. This is not the meaning of an empty table. Multiple attribute definitions are bounded by parentheses. Each attribute definition is separated by a comma. The attribute names are different from each other. They can be arranged in any order. Generally, they are arranged according to the order of the attributes defined by the entity or connection. Foremost, this makes it easy to distinguish and prevents missing defined attributes. [6]
- Each attribute consists of the column name, data type, and multiple integrity constraints for the column. The column name is generally the English abbreviation of the attribute. Chinese can also be used in Microsoft Access 2010. It is not recommended to do this, which is inconvenient when programming. [6]
- Integrity constraints are divided into column-level integrity constraints and table-level integrity constraints. If the integrity constraint condition involves multiple attribute columns of the table, it must be defined at the table level, otherwise it can be defined at the column level. Levels can also be defined at the table level. These integrity constraints are stored in the system's data dictionary. When the user manipulates the data in the table, the RDBMS automatically checks whether the operation violates these integrity constraints. If it is violated, the RDBMS rejects the operation, thus maintaining the correct database state And integrity, without the need for users to provide checks, improve programming efficiency and reduce programming difficulty. Column-level integrity is usually the definition of the primary key and whether it is allowed to be empty. Table-level integrity constraints are generally defined by foreign code. [6]
Structured query language data manipulation
- Data manipulation language is a command to complete data manipulation, and is generally divided into two types of data manipulation. [5]
- Data retrieval (commonly called query): find the specific data needed. [5]
- Data modification: insert, delete and update data. [5]
- Data manipulation language generally consists of INSERT (insert), DELETE (delete), UPDATE (update), SELECT (retrieval, also called query) and so on. Because SELECT is often used, it is generally called a query (retrieval) language and appears separately. [5]
Structured query language data management
- The data management (also known as data control) language is used to manage (or control) user access rights. Consists of GRANT (REGULATE) and REVOKE (Recycle) commands. Visual Foxpro6 does not support this kind of permission management. [5]
SQL Data query in structured query language SQL
- The data in the database is often for query, so data query is the core operation of the database. In SQL, there is only one query language, the SELECT statement. [5]