Introducing SQL
SQL (structured query Language, Structure queries language) is a powerful database language. SQL is typically used to make communications for a database. ANSI (American National Standards Institute) claims that SQL is the standard language for relational database management systems. SQL statements are typically used to perform operations on a database, such as updating data in a database or retrieving data from a database. Common relational database management systems that use SQL are Oracle, Sybase, Microsoft SQL Server, Access, Ingres, and so on. Although most database systems use SQL, they also have their own proprietary extended functionality for their systems. However, standard SQL commands such as "Select", "Insert", "Update", "Delete", "Create", and "Drop" are often used to complete most database operations.
However, unlike other languages, such as C, Pascal, and so on, SQL does not have the function of looping structures (such as If-then-else, do-while) and function definitions. And SQL has only one fixed set of data types, in other words, you can't create your own data types while using other programming languages.
SQL is powerful, but, in summary, it can be divided into the following groups:
DML (data manipulation Language, Operation language): for retrieving or modifying data;
DDL (data definition Language): Used to define the structure of data, such as creating, modifying, or deleting database objects;
DCL (Data Control Language language): Defines permissions for database users.
DML groups can be subdivided into the following statements:
SELECT: for retrieving data;
INSERT: For adding data to the database;
UPDATE: Used to modify existing data from the database
Delete: Used to delete data from the database.
DDL statements can be used to create users and rebuild database objects. Here is the DDL command:
CREATE TABLE
ALTER TABLE
DROP TABLE
CREATE INDEX
DROP INDEX
The DCL command is used to create a relationship user access and an authorized object. Here are a few DCL commands:
ALTER PASSWORD
GRANT
REVOKE
CREATE synonym
To give you an intuitive understanding of SQL, here's an example of a simple SQL statement:
We use SQL statements to retrieve the names of department ID CS from Employees:
SELECT Employees.name
From Employees
WHERE Employees.deptid = "CS"
Perhaps you do not understand these statements at first, maybe you will confused, it does not matter, after the study of this tutorial, you will find this statement is how ordinary. In order not to let you confused, I also explain the following:
For the FROM clause, the FROM employees in the statement means that the data is retrieved from the Employees table.
And the statement where Employees.deptid = "cs" means to retrieve the row of the Employees deptid column "CS", so that the result of the SQL statement retrieval will be all the data of the columns DeptID as CS, for example:
EmpID
|
Name
|
Dept
|
123
|
Purple
|
Cs
|
124
|
Zsc
|
Cs
|
Finally, we explain a SELECT clause that specifies all the data retrieved from the Name column, such as
OK, let's start the tutorial in the next section-------the basics of the table.