1、创建数据库:
CREATE DATABASE database_name;
2、选择数据库:
USE database_name;
3、创建表:
CREATE TABLE table_name (
column1 data_type,
column2 data_type,...);
4、插入数据:
INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,...);
5、查询数据:
SELECT column1, column2,... FROM table_name;
6、更新数据:
UPDATE table_name SET column1 = value1, column2 = value2,... WHERE condition;
7、删除数据:
DELETE FROM table_name WHERE condition;
8、条件查询:
SELECT * FROM table_name WHERE condition;
9、排序查询:
SELECT * FROM table_name ORDER BY column1 ASC/DESC;
10.聚合函数:
COUNT(*), SUM(column), AVG(column), MIN(column), MAX(column)
- 连接查询:
- 内连接:
SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column;
-
外连接:
-
左外连接:
SELECT * FROM table1 LEFT OUTER JOIN table2 ON table1.column = table2.column;
- 右外连接:
SELECT * FROM table1 RIGHT OUTER JOIN table2 ON table1.column = table2.column;