Introduction SQL
SQL (Structured Query Language, Structure Query Language) is a powerful database language. SQL is usually communications in the database. ANSI (National Standard Society) claims that SQL is a standard language for relational database management systems. SQL statements are often used to complete some database operation tasks, such as updating data in the database, or retrieving data from the database. Common relational database management systems using SQL include: Oracle, Sybase, Microsoft SQL Server, Access, Ingres, etc. Although most database systems use SQL, they also have their systems for their systems for their own existing proprietary features. However, standard SQL commands, such as "SELECT", "INSERT", "Update", "Delete", "Create", and "DROP" are often used to complete the operation of most databases.
However, unlike other languages, such as C, Pascal, etc., SQL has no looping structure (such as if-dam, do-whiled, and function definition, etc.). And SQL only has a fixed setting of a data type. In other words, you cannot create your own data type when using other programming languages.
SQL is powerful, but summarizes, it can be divided into the following groups:
DML (Data Manipulation Language, Data Operation Language): Used to retrieve or modify data;
DDL (Data Definition Language, Data Definition Language): The structure used to define data, such as creating, modifying, or deleting database objects;
DCL (Data Control Language, Data Control Language): The permissions used to define database users.
The DML group can be subdivided into the following statements:
SELECT: Used to retrieve data;
INSERT: Used to increase data to the database;
Update: Used to modify existing data from the database
DELETE: Used to remove data from the database.
DDL statements can be used to create users and rebuild database objects. Below is the DDL command:
Create Table
Alter Table
Drop table
Create Index
Drop Index
DCL commands are used to create relational users access and authorized objects. Here is a few DCL commands:
Alter Password
Grant
Revoke
Create Synonym
In order to let you have an intuitive understanding of SQL, the following will give an example of a simple SQL statement:
We use the SQL statement to retrieve the department ID from the Employees:
Select Employees.name
From Employees
WHERE EMPLOYEES.DEPTID = "CS"
Maybe you don't understand these statements at the beginning, maybe you will fog, don't matter, after learning this tutorial, you will find how ordinary this statement is. In order not to let you confuse, I will explain it below:
First, from the FROM clause, the from Employees in the statement means retrieving data from the Employees table.
And statement where employees.deptid = "cs" means retrieving the demployees of DeptID listed as "CS", so the result of SQL statement retrieval will be all data for the column of DeptID, such as Empid Name Dept 123 Purple CS 124 ZSC CS
Finally, let's explain a SELECT clause, which specifies all the data from the Name column, such as
Name Purple ZSC
Ok, get started our tutorial in the next section ----- The basic knowledge of the table.