[Database] database entry (c): SQL

SQL: Structured Query Language (Structured Query Language)

       SQL is generated first developed by IBM, which is one of the earliest relational database of commercial language. In 1974, IBM company's San Jose, California research lab DDChamberlin and RF Boyce developed a specification language SEQUEL (Structured English Query Language), and of the R & D released a new version in November 1976 of the IBM Journal of SQL (called SWQUEL / 2). In 1980 it changed its name to SQL.

       In 1986, the United States uses ANSI standard SQL language as a relational database management system (ANSI X3. 135-1986), the International Organization for Standardization (ISO) adopted as international standards.

       In 1989, the United States adopted ANSI SQL standard language for relational database management system defined in ANSI X3.135-1989 report, known as ANSI SQL 89, the standard ANSI X3.135-1986 alternative version.

       In 1999, SQL continues to expand and divide the core functionality and divided into different packages according to these features.

       In 2003, SQL continues to expand, and may allow XML support.

       In 2011, SQL continues to expand, improve support for temporary databases.

 

With the relational data model are different, the main set of the processing target relational database, i.e. duplicate set can not appear; SQL the main process is a multi-set, i.e., SQL allows objects in relation to a data duplicate.

SQL relational database to provide a number of interfaces, is an advanced non-procedural programming languages, including:

  • Data Definition Language (DDL: Data Definition Language)
  • Data Manipulation Language (DML: Data Manipulation Language)
  • Data Control Language (DCL: Data Control Language)
  • Transaction Control Language (TCL: transaction Control Language)

It is emphasized that, in the course of the SQL language, we often use the keywords in capital letters, while the other variable names, etc., generally in lower case letters or specific implementation in accordance with its own meaning.

 

Data Definition Language (DDL: Data Definition Language)

1. Create a table (CREATE TABLE)

Use CREATE TABLE to create a new pattern of relations, declared its table names, attributes, you can also specify restrictions for each attribute and the table itself restrictions. The basic format such as:

CREATE TABLE table_name
    (attr_name data_type [attr constraints],
     ...,
     attr_name data_type [attr constraints],
     [table constraints]);

  

A few examples:

StudentID Name DOB Email

 


CREATE TABLE Student (StudentID INT, Name VARCHAR(50), DoB Date, Email VARCHAR(100));  

 

No Cname Unit

 

CREATE TABLE Course
    (No VARCHAR(20),
     Cname VARCHAR(50),
     Unit SMALLINT);  

 

StudentID CourseNo Semester Status

 


CREATE TABLE Enrol (StudentID INT, CourseNo VARCHAR(20), Semester VARCHAR(50), Status VARCHAR(50));

  

2. The data type of the attribute


There are common attributes of data types 4, are numeric (Numeric), string (String), date and time (Date and time) and Boolean (Boolean).

  • Numeric
    • Integer: INT, SMALLINT
    • Float: FLOAT, REAL, DOUBLE PRECISION
    • Specifies display digits: NUMERIC (i, j), DECIMAL (i, j). Wherein i is a precision, expressed in total number of digits of the display; J is a range, the number of bits of display digits after the decimal point.
  • String
    • CHAR (n): n specified length string attributes.
    • VARCHAR (n): n variable length attribute string specifies the maximum allowed length .
    • BIT (n): n bit string of a specified length.
    • BIT VARYING (n): n variable specifies the maximum permissible length of a bit string.
  • Date and Time
    • DATE :( year, month, day) / (year, month, day).
    • When TIME :(, minutes, seconds) / (hour, minute, second).
    • TIMESTAMP: date and time, accurate to a minimum of six seconds, and may define the time zone selected.
    • INTERVAL: specifies a relative value, for increasing or decreasing a value corresponding to three types of data described above.
  • Boolean: TRUE and FALSE contains two values.

When we create a property, the corresponding configuration data type of the property will be. Depending on demand, using the above data types, sometimes we will customize some of the new data types, use the CREATE DOMAIN statement, such as:

CREATE DOMAIN ssn_type AS CHAR(9);

  

3. Properties of constraints

Commonly used in SQL statements property constraints are the following:

  • NOT NULL: the value of the statement attribute can not be empty.
  • DEFAULT: specify a default value for the property.
  • CHECK (attr> 0): The current value of the attribute data is defined within a range.
  • UNIQUE: ensuring the uniqueness of a value of a property or properties in the table, i.e. not duplicate or attribute value.
  • PRIMARY KEY: this attribute as the primary key to uniquely identify a tuple in a table.
  • FOREIGN KEY: to achieve the implementation of referential integrity between two related tables.
  • INDEX: using the index more quickly access a particular row of the table.

Which, PRIMARY KEY, and UNIQUE constraint property comes with constraint NOT NULL, that is, to be bound by the primary key or unique property, it must not be empty.

If the primary key contains only one attribute, PRIMARY KEY attribute may be defined later; if the primary key comprises a plurality of attributes, PRIMARY KEY constraints to define a table, such as:

-- PRIMARY KEY 定义在属性后 
CREATE TABLE Course
    (No VARCHAR(20) PRIMARY KEY,
     Cname VARCHAR(50) UNIQUE,
     Unit SMALLINT not null Default 6);

-- PRIMARY KEY 定义在表约束中
CREATE TABLE Enrol
    (StudentID INT not null CHECK (StudentID>0),
     CourseNo VARCHAR(20) not null,
     Semester VARCHAR(50) not null,
     Status VARCHAR(50),
     PRIMARY KEY(StudentID, CourseNo, Semester),
     ...);

  

The following is an example of the specified FOREIGN KEY:

CREATE TABLE Enrol
    (StudentID INT,
     CourseNo VARCHAR(20),
     Semester VARCHAR(50),
     Status VARCHAR(50),
     FOREIGN KEY(StudentID) REFERENCES Student(StudentID),
     FOREIGN KEY(CourseNo) REFERENCES Course(No));

  

INDEX examples:

CREATE TABLE Customer
    (CustomerID INT not null CHECK (CustomerID>0),
     Name VARCHAR(50) not null,
     DOB DATE not null,
     Address VARCHAR(80),
     Phone INT CHECK (Phone>0),
     PRIMARY KEY(CustomerID));

CREATE INDEX index1 ON Customer (Name, DOB);
CREATE UNIQUE INDEX index2 ON Customer (Phone);

  

4. Change and delete tables

Use ALTER TABLE commonly used to change the contents of the table already exists, you can make the changes include:

 

  • Modify the table name
  • Add or delete attributes
  • Modify the definition of property
  • Add or delete a table constraint
ALTER TABLE Customer ALTER COLUMN Address SET NOT NULL;

ALTER TABLE Customer ADD UNIQUE(Phone);

ALTER TABLE Customer ADD CONSTRAINT positive_id CHECK (CustomerID > 0);

ALTER TABLE Enrol ADD FOREIGN KEY(StudentID) REFERENCES Student(StudentID);

ALTER TABLE Customer ADD Email VARCHAR(100);

  

Table DROP TABLE commonly used to remove an already created

DROP TABLE Enrol;

DROP TABLE IF EXISTS Customer;

  

Data Manipulation Language (DML: Data Manipulation Language)

     Data Manipulation Language primarily includes four command: INSERT, UPDATE, DELETE, SELECT.

1. INSERT command to insert

INSERT command is used to add the new tuple or a new entry to the table, the main format:

INSERT INTO table_name
    [(attribute_name,...,attribute_name)]
    VALUES (value,...,value),...,(value,...,value);

  

The previous article in this series have already mentioned the contents of relational database integrity constraints: When we execute INSERT, UPDATE, DELETE command, could lead to violations of integrity constraints. About content integrity constraints, you can see this blog: [database] database entry (B): a relational database .

Violation of primary key constraint

Primary key as an independent identification of a tuple in a table, different tuples which correspond to the primary key value can not be the same, or primary key constraint violation. For example the following table:

StudentID Name DOB Email

456

Tom 25/01/1988 [email protected]
458 Peter 20/02/1991 [email protected]
... ... ... ...

If at this table, we'll insert the following command:

INSERT INTO Student(StudentID, Name, DoB, Email)
    VALUES (456, 'Smith', '27/08/1989', '[email protected]');

  

I.e., the same primary key is inserted into a 456, but the remaining values ​​of a new tuple different. If the tuple can be added to the table, the master keys from the two tuples is present i.e. StudentID 456, then we have the primary key StudentID and can not recognize a separate tuple, and therefore a violation of a primary key constraint, it is above this insertion command It will not be executed properly. DBMS does not allow two identical primary key exists tuples in a table.

Foreign key constraint violation

When foreign key constraint violation occurs often in a case where a plurality of interrelated tables referenced by a tuple in a table that is newly added, a value corresponding to the outer keys and does not appear in another table, it will lead to foreign key constraint violation . For example, the following two tables:

StudentID Name DOB Email

456

Tom 25/01/1988 [email protected]
458 Peter 20/02/1991 [email protected]
... ... ... ...

 

StudentID CourseNo Semester Status EnrolDate
456 COMP1111 2017 S1 active 25/02/2017
458 COMP2222 2017 S2 active 09/06/2017

Then we insert the following command:

INSERT INTO Enrol(StudentID, CourseNo, Semester, Status)
    VALUES (460, 'COMP2400', '2016 S2', 'active');

  

Imagine such a reality: in one semester registration information database stores a student to attend a course in the semester, but the students are not in school personal record data, this situation is very unreasonable . The registration form must depend on the student information table exists, so the above command can not be executed successfully. DBMS will not allow the presence of such a table a tuple: foreign key value corresponding to the corresponding foreign key referencing table does not exist.

 

2. UPDATE command

UPDATE command used for modifying values ​​or a plurality of tuples corresponding attribute, which is the main form:

UPDATE table_name
    SET attribute_name = value,...,attribute_name = value
    [WHERE selection_condition];

  

3. DELETE command

Used to remove the DELETE command presence tuples from the table, the main format:

DELETE FROM table_name
    [WHERE selection_condition];

  

Delete command to delete operation according to the specific conditions, you can also delete all tuples in the table.

-- Delete the tuple whose studentID equals to 456.
DELETE FROM Student WHERE StudentID=456;

-- Delete all tuple in Student relation.
DELETE FROM Student;

  

It should be noted that the difference between DELETE and DROP effect is not the same. DELETE FROM Student will clear all tuples in the Student table, after executing the command table still exists, and is empty table; and DROP TABLE Student not only clear all tuples, also removes the Student table, the table will not execute the command longer exist.

 

Reference behavior between tables

Because of mutual relationships between tables referenced relational database, so we will want when you modify the contents of a table, which has a reference table relations corresponding content can also be followed sync change. So SQL offers the following keywords:

  • The ACTION NO (default): When you modify or delete an existing reference tuple relations, the system will throw an error message error.
  • CASCADE : Delete or update operation will be carried out simultaneously with all references to the relationship.
  • NULL the SET : the delete or update operation, the presence of the corresponding reference attribute tuples of relations will be set to NULL.
  • The DEFAULT the SET : the delete or update operation, the presence of the corresponding reference attribute tuples of relations will be set to a specified default value.

Keywords used in the above definition table as a foreign key attributes, the following is an example:

CREATE TABLE Enrol
    (StudentID INT,
     CourseNo VARCHAR(20),
     Semester VARCHAR(50),
     Status VARCHAR(50),
     FOREIGN KEY(StudentID) REFERENCES Student(StudentID)
         ON DELETE NO ACTION ,
     FOREIGN KEY(CourseNo) REFERENCES Course(No));

  

4. SELECT command

SELETE commands used to retrieve data from the database, mainly the following format:

SELECT attribute_list
    FROM table_list
    [WHERE condition]
    [GROUP BY attribute_list [HAVING group_condition]]
    [ORDER BY attribute_list [ASC | DESC]];

  

SELETE is followed by an attribute you want to display, if you use an asterisk "*", representing all the attributes to get the value of the specified table.

FROM behind with the name of the table is to be acquired. If a plurality of tables with a comma "," separated, then take the two tuples form All binding results were after the Cartesian product. If JOIN keyword, will be according to the specific JOIN form a plurality of tables are combined, and to choose the target attribute value.

WHERE keyword is followed by the value of the condition, the condition usually determines whether a property is a specified value or magnitude relation satisfies the numerical values.

GROUP BY keywords are grouped according to the back of the specified attribute, i.e. the same attribute value tuples will be classified as a group, the latter may be used HAVING keyword, its function and WHERE similar, but it specifies the divided group in all tuple of required conditions are met. GROUP BY keyword would typically use in conjunction with the following built-in functions:

  • COUNT : statistical value is not NULL of the number of entries.
  • The AVG : Averaging specified parameters.
  • MIN : minimization of the specified parameter.
  • MAX : selecting the maximum value of the specified parameter.
  • The SUM : for obtaining the sum of the specified parameter.

ORDER BY the content retrieval is ordered by the value of a given property, the default sort in ascending order, the keyword may be used ASC specify ascending or DESC specified descending.

 

In-depth content on SELETE command, the next article will be described in detail, and provides some examples to explain.

[Database] database entry (D): SQL query - SELETE advanced use

 

Reference material

Wikipedia: https://zh.wikipedia.org/wiki/SQL

Database basis: Fundamentals of Database Systems, 7th Edition (Global Edition), R. Elmasri and S. Navathe, 2017

SQL: Structured Query Language (Structured Query Language) SQL is generated first developed by IBM, which is one of the earliest relational database of commercial language. In 1974, IBM company's San Jose, California research lab DDChamberlin and RF Boyce developed a specification language SEQUEL (Structured English Query Language), and of the R & D released a new version in November 1976 of the IBM Journal of SQL (called SWQUEL / 2). 1980 changed its name to SQL.
       In 1986, the United States uses ANSI standard SQL language as a relational database management system (ANSI X3. 135-1986), the International Organization for Standardization (ISO) adopted as international standards.
       In 1989, the United States adopted ANSI SQL standard language for relational database management system defined in ANSI X3.135-1989 report, known as ANSI SQL 89, the standard ANSI X3.135-1986 alternative version.
       In 1999, SQL continues to expand and divide the core functionality and divided into different packages according to these features.
       In 2003, SQL continues to expand, and may allow XML support.
       In 2011, SQL continues to expand, improve support for temporary databases.
 
With the relational data model are different, the main set of the processing target relational database, i.e. duplicate set can not appear; SQL the main process is a multi-set, i.e., SQL allows objects in relation to a data duplicate.
SQL relational database to provide a number of interfaces, is an advanced non-procedural programming languages, including:
Data Definition Language (DDL: Data Definition Language) data manipulation language (DML: Data Manipulation Language) Data Control Language (DCL: Data Control Language) Transaction Control Language (TCL: transaction Control Language) needs to be emphasized that the use of the SQL language process, we often use the keywords in capital letters, while the other variable names, etc., generally in lower case letters or specific implementation in accordance with its own meaning.
 
Data Definition Language (DDL: Data Definition Language). 1 Create a table (CREATE TABLE) Use CREATE TABLE to create a new pattern of relations, declared its table names, attributes, you can also specify restrictions for each attribute and the table itself limitation factor. The basic format such as:
the CREATE TABLE table_name (data_type attr_name [attr Constraints], ..., attr_name data_type [attr Constraints], [Table Constraints]); a few examples:
StudentIDNameDoBEmailCREATE TABLE Student (StudentID INT, Name VARCHAR (50), DoB Date, Email VARCHAR (100)); NoCnameUnitCREATE TABLE Course (No VARCHAR (20), Cname VARCHAR (50), Unit SMALLINT); StudentIDCourseNoSemesterStatusCREATE TABLE Enrol (StudentID INT, CourseNo VARCHAR (20), Semester VARCHAR (50), Status VARCHAR (50));. 2 data type attribute of the attribute data types are used in 4, are numeric (numeric), string (string), date and time (Date and time) and boolean (Boolean).
Numeric integer: INT, SMALLINT float: FLOAT, REAL, DOUBLE PRECISION specify display digits: NUMERIC (i, j), DECIMAL (i, j). Wherein i is a precision, expressed in total number of digits of the display; J is a range, the number of bits of display digits after the decimal point. String CHAR (n): n specified length string attributes. VARCHAR (n): n variable specifies a maximum permitted length of the attribute string. BIT (n): n bit string of a specified length. BIT VARYING (n): n variable specifies the maximum permissible length of a bit string. Date and Time DATE :( year, month, day) / (year, month, day ). When TIME :(, minutes, seconds) / (hour, minute, second ). TIMESTAMP: date and time, accurate to a minimum of six seconds, and may define the time zone selected. INTERVAL: specifies a relative value, for increasing or decreasing a value corresponding to three types of data described above. Boolean: TRUE and FALSE contains two values. When we create a property, the corresponding configuration data type of the property will be. Depending on the requirements, using the data type, we will sometimes new custom data types, using CREATE DOMAIN statement, such as:
. CREATE DOMAIN ssn_type the AS CHAR (. 9); attribute constraints. 3 used in the SQL statement the property constraints are the following:
NOT NULL: the value of the statement attribute can not be empty. DEFAULT: specify a default value for the property. CHECK (attr> 0): The current value of the attribute data is defined within a range. UNIQUE: ensuring the uniqueness of a value of a property or properties in the table, i.e. not duplicate or attribute value. PRIMARY KEY: this attribute as the primary key to uniquely identify a tuple in a table. FOREIGN KEY: to achieve the implementation of referential integrity between two related tables. INDEX: using the index more quickly access a particular row of the table. Which, PRIMARY KEY, and UNIQUE constraint property comes with constraint NOT NULL, that is, to be bound by the primary key or unique property, it must not be empty.
If the primary key contains only one attribute, PRIMARY KEY be defined later attribute; if the primary key comprises a plurality of attributes, PRIMARY KEY To define Table constraints, such as:
- PRIMARY KEY defined in the attribute CREATE TABLE Course (No VARCHAR (20 ) PRIMARY KEY, Cname VARCHAR (50 ) UNIQUE, Unit SMALLINT not null Default 6); - PRIMARY KEY defined CREATE tABLE Enrol (StudentID INT not null CHECK (StudentID> 0) in the table constraints, CourseNo VARCHAR (20) not null , Semester VARCHAR (50) not null , Status VARCHAR (50), PRIMARY KEY (StudentID, CourseNo, Semester), ...); the following is an example of the specified FOREIGN KEY:
CREATE TABLE Enrol (StudentID INT, CourseNo VARCHAR (20), Semester VARCHAR (50), Status VARCHAR (50), FOREIGN KEY (StudentID) REFERENCES Student (StudentID), FOREIGN KEY (CourseNo) REFERENCES Course (No)); INDEX of examples:
the CREATE TABLE the Customer (the CustomerID the INT Not null the CHECK (the CustomerID> 0), the Name VARCHAR (50) Not null, DOB DATE Not null, the Address VARCHAR (80), Phone the INT the CHECK (Phone> 0), a PRIMARY KEY (the CustomerID) ); CREATE INDEX index1 ON Customer ( Name, DOB); CREATE UNIQUE INDEX index2 ON Customer (Phone); 4 to change to change the contents of the table already exists and delete a table using ALTER tABLE commonly used, can make the changes include:
modifying table name
Add to add or remove properties to modify the properties of defining or constraining ALTER TABLE Customer Delete table ALTER COLUMN Address SET NOT NULL; ALTER TABLE Customer ADD UNIQUE (Phone); ALTER TABLE Customer ADD CONSTRAINT positive_id CHECK (CustomerID> 0); ALTER TABLE Enrol ADD FOREIGN KEY (StudentID) REFERENCES Student ( StudentID); ALTER tABLE Customer ADD Email VARCHAR (100); DROP tABLE commonly used to remove a table created
DROP tABLE Enrol; DROP tABLE IF EXISTS  Customer;
data manipulation language (DML: data manipulation language) data manipulation language mainly includes four command: INSERT, UPDATE, DELETE, SELECT .
1. INSERT command INSERT command used to insert new tuple is added or a new entry to a table, which is the main form:
INSERT the INTO table_name [(ATTRIBUTE_NAME, ..., ATTRIBUTE_NAME)] the VALUES (value, ..., value ), ..., (value, ... , value); the previous article in this series have already mentioned the contents of relational database integrity constraints: when we execute INSERT, UPDATE, DELETE command, you may lead to violations of integrity constraints. About content integrity constraints, you can see this blog: [database] database entry (B): a relational database.
Primary key constraint violation of a primary key as an independent identification of a tuple in a table, different tuples which correspond to the primary key value can not be the same, or primary key constraint violation. For example the following table:
StudentIDNameDoBEmail456
Tom25 / 01 / 1988tom @ gmail.com458Peter20 / 02 / 1991peter @ hotmail.com ............ If this table, we then execute the following insert command:
INSERT INTO Student (StudentID, Name, DoB, Email) vALUES (456, 'Smith', '27 / 08/1989 ',' [email protected] '); i.e., a new primary key is inserted a likewise 456, but with different values of the remaining tuples. If the tuple can be added to the table, the master keys from the two tuples is present i.e. StudentID 456, then we have the primary key StudentID and can not recognize a separate tuple, and therefore a violation of a primary key constraint, it is above this insertion command It will not be executed properly. DBMS does not allow two identical primary key exists tuples in a table.
When foreign key constraint violation foreign key constraint violation occurs often in a case where a plurality of interrelated tables referenced by a tuple in a table that is newly added, a value corresponding to the outer keys and does not appear in another table, it will lead to foreign key constraint violation. For example, the following two tables:
StudentIDNameDoBEmail456
Tom25 / 01 / 1988tom @ gmail.com458Peter20 / 02 / 1991peter @ hotmail.com ............ StudentIDCourseNoSemesterStatusEnrolDate456COMP11112017 S1active25 / 02 / 2017458COMP22222017 S2active09 / 06/2017 then we insert the following command:
INSERT INTO Enrol (StudentID, CourseNo, Semester, Status) VALUES (460, 'COMP2400', '2016 S2', 'active'); imagine such a reality: in one semester a student database stored in the semester registration information to attend a course, but the students are not in school personal record data, this situation is very unreasonable. The registration form must depend on the student information table exists, so the above command can not be executed successfully. DBMS will not allow the presence of such a table a tuple: foreign key value corresponding to the corresponding foreign key referencing table does not exist.
2. UPDATE command UPDATE command used to modify the value of the corresponding attribute or a plurality of tuples, the main format:
UPDATE table_name the SET ATTRIBUTE_NAME = value, ..., ATTRIBUTE_NAME = value [the WHERE selection_condition]; the DELETE command. 3 DELETE. command used to remove the presence tuples from the table, which is the primary format:
the dELETE the fROM table_name [the WHERE selection_condition]; delete command to delete operation according to the specific conditions, you can also delete all tuples in the table.
- Delete the tuple whose studentID equals to 456.DELETE FROM Student WHERE StudentID = 456; - Delete all tuple in Student relation.DELETE FROM Student; note here the difference between DELETE and DROP effect is not the same. DELETE FROM Student will clear all tuples in the Student table, after executing the command table still exists, and is empty table; and DROP TABLE Student not only clear all tuples, also removes the Student table, the table will not execute the command longer exist.
Behavior between the reference table due to the presence of each other relational database reference relationships between tables, so we will want when you modify the contents of a table, which has a reference table relations corresponding content can also be followed sync change. So SQL offers the following keywords:
NO the ACTION (default): When you modify or delete an existing reference tuple relations, the system will throw an error message error. CASCADE: Delete or update operation will be carried out simultaneously with all references to the relationship. SET NULL: the delete or update operation, the presence of the corresponding reference attribute tuples of relations will be set to NULL. SET DEFAULT: after delete or update operation, the presence of the corresponding reference attribute tuples of relations will be set to a specified default value. Keywords used in the above definition table as a foreign key attributes, the following is an example:
CREATE TABLE Enrol (StudentID INT, CourseNo VARCHAR (20), Semester VARCHAR (50), Status VARCHAR (50), FOREIGN KEY (StudentID) REFERENCES Student (StudentID) ON DELETE NO ACTION, FOREIGN KEY (CourseNo) REFERENCES Course (No) .); 4 SELECT command SELETE commands used to retrieve data from the database, mainly the following format:
the SELECT attribute_list the fROM table_list [the WHERE for condition Condition] [the GROUP BY attribute_list [the HAVING group_condition]] [the oRDER BY attribute_list [the ASC | DESC]]; SELETE It is followed by an attribute you want to display, if you use an asterisk "*", representing all the attributes to get the value of the specified table.
FROM behind with the name of the table is to be acquired. If a plurality of tables with a comma "," separated, then take the two tuples form All binding results were after the Cartesian product. If the keyword JOIN is used, depending upon the particular form will JOIN binding of a plurality of tables, and to choose the target attribute value.
WHERE keyword is followed by the value of the condition, the condition usually determines whether a property is a specified value or magnitude relation satisfies the numerical values.
GROUP BY keywords are grouped according to the back of the specified attribute, i.e. the same attribute value tuples will be classified as a group, the latter may be used HAVING keyword, its function and WHERE similar, but it specifies the divided group in all tuple of required conditions are met. GROUP BY keyword would typically use in conjunction with the following built-in functions:
COUNT: statistical value is not NULL of the number of entries. AVG: Averaging specified parameters. MIN: minimization of the specified parameter. MAX: selecting the maximum value of the specified parameter. SUM: for obtaining the sum of the specified parameter. ORDER BY the content retrieval is ordered by the value of a given property, the default sort in ascending order, may be used to specify a keyword ASC ascending or descending DESC specified.
 
In-depth content on SELETE command, the next article will be described in detail, and provides some examples to explain.
[Database] database entry (D): SQL query - SELETE use of Advanced
 
Resources Wikipedia: https: //zh.wikipedia.org/wiki/SQL
database infrastructure: Fundamentals of Database Systems, 7th Edition (Global Edition), R. Elmasri and S. Navathe, 2017 ---------------- Disclaimer: This article is CSDN blogger "Wyman mosquitoes' original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. Original link: https: //blog.csdn.net/sinat_36645384/article/details/100557776

Guess you like

Origin www.cnblogs.com/wymanwong/p/11531588.html