*所有表格、列的名称都不能包含空格或者关键字,比如select, table等
*所有改变都不能撤销,删除或者改变表中的值时可以先用SELECT来确认要改变的值是否正确
SELECT:
一般格式:
SELECT (DISTINCT) col_name, COUNT(), AVG(), MIN(), MAX(), SUM() AS alias FROM table_name
(WHERE ... LIKE 'some_pattern')
(GROUP BY ... HAVING 用来在group by 结果中搜索的分句)
(ORDER BY col_name1, col_name2 DESC)
CREATE :
一般格式:
CREATE TABLE tablename(
column_name data_type attributes...,
column_name data_type attributes...,
)
INSERT:(插入行)
一般格式:
INSERT INTO table_name
VALUES (按照列的顺序输入每个值,注意数据类型)
或
INSERT INTO table_name (col1, col2, ...)
VALUES (按照上面所说的列顺序输入值)
UPDATE:(改变表中的值)
一般格式:
UPDATE table_name
SET col_name = new_value, ...
WHERE col_name = some_value
DELETE:(删除行)
一般格式:
DELETE FROM table_name
WHERE col_name = some_value #此行不写的话就会删除所有行,慎重慎重
DROP:(删除表)
一般格式:
DROP TABLE table_name
网友评论