【131202】SQL
SELECT
TOP 2
* FROM PersonsSELECT *FROM PersonsWHERE ROWNUM <= 5
SELECT * FROM Persons WHERE City LIKE '%lond%'
SELECT * FROM Persons WHERE LastName LIKE 'C_r_er'
SELECT * FROM Persons WHERE LastName
BETWEEN
'Adams' AND
'Carter'JOIN: 如果表中有至少一个匹配,则返回行 = INNER JOIN(内连接)
LEFT JOIN: 即使右表中没有匹配,也从左表返回所有的行
RIGHT JOIN: 即使左表中没有匹配,也从右表返回所有的行
FULL JOIN: 只要其中一个表中存在匹配,就返回行
SELECT * INTO
Persons_backup FROM Persons
= creat table persons_backup as select * from persons;
CREATE TABLE Persons
(
Id_P int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),CHECK (Id_P>0)
)
DEFAULT 约束用于向列中插入默认值。
ALTER TABLE table_name ADD column_name datatype
ALTER TABLE table_name DROP COLUMN column_name