Manipulation:
创建:
create(
constraint
)
插入行: INSERT INTO table_name
插入列: ALTER TABLE table_name ADD COLUMN col_name
删除: DELETE FROM table_name ...
修改: SET + WHERE
Query:
Rename: SELECT ...AS...
Distinct: SECT DISTINCT
Where: 没啥好说的
Like: where ... like '_' _ is a wildcard for any individual character
% is a wildcard for zero or more missing letters
note: not case-sensitive
BETWEEN: between 2 letters: not include the 2nd character;
between 2 numbers: include the 2nd number
AND/OR: combine where clauses
ORDER BY: always after where
LIMIT:
CASE: case+end, handing if-then cases.
Aggregate functions:
COUNT: COUNT(*)
SUM: SUM(*)
ROUND: ROUND(number, 2) 保留两位小数
GROUP BY: after WHERE before ORDER BY and LIMIT
HAVING: after GROUP BY before ORDER BY and LIMIT
Multi-table functions:
JOIN:
INNER JOIN: 取条件的交集
LEFT JOIN: 左边一定保留
Primary key vs foreign key:
pk is unique for each table. Foreign key is primary key in other tables and it is called a foreign key when it appeared in table else.
UNION:
stacking
WITH
WITH previous_results AS(
做操作
)
w3school:
您的回答:Structured Query Language
您的回答:SELECT
您的回答:UPDATE
您的回答:DELETE
您的回答:INSERT INTO
您的回答:SELECT FirstName FROM Persons
您的回答:SELECT * FROM Persons
您的回答:SELECT * FROM Persons WHERE FirstName='Peter'
您的回答:SELECT * FROM Persons WHERE FirstName LIKE 'a%'
您的回答:正确
您的回答:SELECT * FROM Persons WHERE FirstName='Thomas' AND LastName='Carter'
您的回答:SELECT * FROM Persons WHERE LastName BETWEEN 'Adams' AND 'Carter'
您的回答:SELECT DISTINCT
您的回答:ORDER BY
您的回答:SELECT * FROM Persons ORDER BY FirstName DESC
您的回答:INSERT INTO Persons VALUES ('Jimmy', 'Jackson')
您的回答:INSERT INTO Persons (LastName) VALUES ('Wilson')
您的回答:UPDATE Persons SET LastName='Wilson' WHERE LastName='Gates'
您的回答:DELETE ROW FirstName='Fred' FROM Persons
正确答案:DELETE FROM Persons WHERE FirstName = 'Fred'
您的回答:SELECT COUNT(*) FROM Persons