目录 还有其他的连接类型,如
1. 创建数据库
CREATE DATABASE database_name;
2. 删除数据库
DROP DATABASE database_name;
3. 使用数据库
USE database_name;
4. 创建表
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
...
);
5. 删除表
DROP TABLE table_name;
6. 插入数据
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
7. 查询数据
SELECT column1, column2, ...
FROM table_name
WHERE condition;
8. 更新数据
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
9. 删除数据
DELETE FROM table_name
WHERE condition;
10. 连接两个或多个表
SELECT columns
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;
LEFT JOIN
, RIGHT JOIN
, 和 FULL JOIN
。
11. 排序数据
SELECT column1, column2, ...
FROM table_name
ORDER BY column1 [ASC|DESC], column2 [ASC|DESC], ...;
12. 限制返回的数据数量
SELECT column1, column2, ...
FROM table_name
LIMIT number;
13. 创建索引
CREATE INDEX index_name
ON table_name (column1, column2, ...);
14. 删除索引
DROP INDEX index_name
ON table_name;
15. 创建主键
ALTER TABLE table_name
ADD PRIMARY KEY (column1, column2, ...);
16. 删除主键
ALTER TABLE table_name
DROP PRIMARY KEY;
17. 创建外键
ALTER TABLE child_table_name
ADD FOREIGN KEY (child_column_name)
REFERENCES parent_table_name (parent_column_name);
18. 删除外键
ALTER TABLE child_table_name
DROP FOREIGN KEY foreign_key_name;