1、 Select rownum(oracle) top(mysql):
Returns the value for the predetermined specified number
Where roenum < number
2、 Like
In where clause search for a specified pattern
Where 列名 [NOT] like ‘%string’ [ESCAPE]’\%(_)’
Where 列名 [NOT] like ‘_string’ [ESCAPE]’\%(_)’
% Denotes: any length
select *
from STUDENT
where SNAME like '张%'
_ Represents any single character
select *
from STUDENT
where SNAME like '张_'
3, wildcards: use with like, as described above
4、 In
Where clause for a predetermined plurality of values satisfies the condition field (available for nested sql statement)
select *
from STUDENT
where id in (1,9,10)
Nest
select *
from STUDENT
where id in (
select ID
from STUDENT
where SNAME like '张%' or SNAME like '刘%'
)
5、 Between
Where clause positioned between two operators in the data range
select *
from STUDENT
where id between 0 and 10
6, alias:
In more than one table involved in the query
Use a function in a query
A long column names or poor readability
Columns need to combine two or more columns
Alias (1) Table
select SNAME,CNAME,CSID
from COURSE as C,STUDENT as S
where S.ID = CE.CSID
ORDER BY CSID
(2) column aliases
select ID as student_ID
from STUDENT
WHERE SSCORE >= 60
7, the connection: means for connecting two or more tables, the same between the plurality of tables based on the field.
8, Inner join table has at least one match, return line
select STUDENT.ID,STUDENT.SNAME
from STUDENT
inner join STUDENT1
ON STUDENT.ID = STUDENT1.ID
9、 Left join
Remove the same field data tables A and B, together with the data left table (A) of the condition is not satisfied
select STUDENT.ID,STUDENT.SNAME
from STUDENT
left join STUDENT1
ON STUDENT.ID = STUDENT1.ID
ORDER BY ID
10、 right join
Remove the right table plus all of the data satisfies the matching condition data
11、 full join
Left table has a matching condition is satisfied return line
Full outer join
12、 union
Search results for merging two or more of the select
select DISTINCT STUDENT1.ID,STUDENT1.SNAME
from STUDENT1
left join STUDENT
ON STUDENT1.ID = STUDENT.ID
union
select DISTINCT STUDENT1.ID,STUDENT1.SNAME
from STUDENT1
right join STUDENT
ON STUDENT1.ID = STUDENT.ID
ORDER BY ID
13、 select into
14、select insert into select
15、create database
16、create table
CREATE TABLE Persons
(
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
17, constraint
18、not null
Column can not be null
19、primary key
Not null and unique combination, to ensure that uniquely identifies a column
20、unique
Constraint uniquely identifies each record in the database table.
21、check
Values that meet certain criteria Proscar
create TABLE student3
(id int CHECK (id > 0)
)
22、Default
Not worth the provisions to the column, assign default values
ALTER table STUDENT3
add score INT
default 0
23、create index
24、drop
DROP index index_name revoked index
drop table student3 delete table
truncate table STUDENT2 delete a table of contents
25、Alert
ALTER TABLE table_name
ADD column_name datatype
To delete a column in a table, use the following syntax (Please note that some database systems do not allow this to delete columns in a database table mode):
ALTER TABLE table_name
DROP COLUMN column_name
To change the data type of the columns in the table, use the following syntax:
SQL Server / MS Access:
ALTER TABLE table_name
ALTER COLUMN column_name datatype
My SQL / Oracle:
ALTER TABLE table_name
MODIFY COLUMN column_name datatype
After Oracle 10G version:
ALTER TABLE table_name
MODIFY column_name datatype;
26、auto increment
Automatically create the next value of the primary field
27 views
28, Date
29, null value
30, null function
31, common data types
32, db Data Type
function
Avg()
Count () satisfy the matching condition of the number of lines you
select count(SSCORE)
from STUDENT
where SSCORE > = 60
Firsr () first rows
SELECT SSCORE,ID
FROM STUDENT
WHERE ROWNUM <= 1
Last () returns the last line records
Max () returns the maximum
Min () returns the minimum
Sum () and return
Group by a field arranged in the positive sequence asc desc flashback
Having conditions, where reason can not be used with an aggregate function
Reference: https://www.runoob.com/sql/sql-tutorial.html