赞
踩
database_name
数据库CREATE DATABASE database_name;
database_name
数据库DROP DATABASE database_name;
USE database_name;
1.创建 table_name
的表,包含指定的列和约束
CREATE TABLE table_name (
column1 datatype constraint,
column2 datatype constraint,
...
);
table_name
的表DROP TABLE table_name;
table_name
表中添加列、修改列定义或删除列ALTER TABLE table_name
ADD column_name datatype constraint,
MODIFY column_name datatype constraint,
DROP column_name;
INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);
SELECT column1, column2, ...
FROM table_name
WHERE condition;
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
DELETE FROM table_name
WHERE condition;
WHERE
关键字对查询结果进行条件过滤SELECT column1, column2, ...
FROM table_name
WHERE condition;
ORDER BY
关键字对查询结果进行排序SELECT column1, column2, ...
FROM table_name
ORDER BY column1 ASC, column2 DESC;
SELECT COUNT(column), SUM(column), AVG(column), MAX(column), MIN(column)
FROM table_name;
column1
进行分组,并使用聚合函数计算其他列的值SELECT column1, aggregate_function(column2)
FROM table_name
GROUP BY column1;
SELECT column1, column2, ...
FROM table1
INNER JOIN table2
ON table1.column = table2.column;
SELECT column1, column2, ...
FROM table1
LEFT JOIN table2
ON table1.column = table
2.column;
CREATE INDEX index_name
ON table_name (column1, column2, ...);
EXPLAIN
关键字分析查询语句,了解查询执行计划和性能优化建议EXPLAIN SELECT column1, column2, ...
FROM table_name
WHERE condition;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。