Definition of L:
SQL is the standard computer language for accessing and working with databases.
- SQL refers to the Structured Query language, the full name is Structured query Language.
- SQL allows you to access and manipulate the database.
- SQL is a computer language of ANSI (American National Standards Institute United States Standardization Organization) standard.
2.RDBMS
- RDBMS refers to the relational database management system, the full name of relational databases Management system.
- The RDBMS is the foundation of SQL and is also the foundation of all modern database systems, such as MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.
- Data in an RDBMS is stored in a database object called a table.
- A table is a collection of related data items that consists of columns and rows.
3.SQL syntax
- Use database name; command to select a database.
- set names UTF8; The command is used to set the character set used.
- SELECT * from Websites; Read the data table information.
- SQL is not case sensitive: Select is the same as select.
- SELECT statement
SELECT name,country from Websites;
SELECT DISTINCT country from Websites; // the SELECT DISTINCT statement is used to return only different values.
SELECT * from Websites WHERE country='CN';
SELECT * from websiteswhere country='CN';
SELECT * from websiteswhere country='USA'OR Country=' CN ';
SELECT * from websitesorder by Alexa; // the default is in ascending order, that is, select * from Websites order by Alexa ASC
SELECT * from websitesorder by Alexa DESC;
The first form does not need to specify the column name to insert the data, just provide the inserted value:
INSERT into Table_namevalues (Value1,value2,value3,...);
The second form requires specifying the column name and the value to be inserted:
INSERT into table_name (COLUMN1,COLUMN2,COLUMN3,...) VALUES (Value1,value2,value3,...);
UPDATE Websites SET alexa='country= ', 'USA' WHERE name=' Rookie tutorial ';
Take extra care when updating records! In the above example, if we omit the WHERE clause, all Alexa and country in the data will be changed
DELETE from websiteswhere name=' Baidu ' and country='CN ';
- Select top, limit, rownum syntax
Not all database systems support the SELECT top syntax, the following is the Sql,ms Access database system
PERCENT * from Websites;
MY SQL Database System
SELECT column_name (s) from table_namelimit number;
Oracle Database System
SELECT *<=5;
Like operator
SELECT *'g%' *'%oo%';
wildcard characters |
Description |
% |
Override one or more characters |
_ |
Replaces only one character |
[Charlist] |
Any single character of the word columns |
[^charlist] Or [!charlist] |
Not any single columns of the word |
Database Learning Notes