创建表: CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 datatype, ..... ); 删除表: DROP TABLE table_name; 插入数据: INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...); 更新数据: UPDATE table_name SET column_name = new_value WHERE column_name = some_value; 删除数据: DELETE FROM table_name WHERE column_name = some_value; 查询数据: SELECT column1, column2, ...FROM table_name WHERE condition; 查询数据并排序: SELECT column1, column2, ...FROM table_name ORDER BY column_name ASC|DESC; 查询数据并分组: SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name; 使用函数查询数据: SELECT AVG(column_name) FROM table_name; 使用子查询查询数据: SELECT column_name(s) FROM table_name WHERE column_name IN (SELECT column_name FROM table_name WHERE condition); 联合查询: SELECT column_name(s) FROM table_name1 UNION SELECT column_name(s) FROM table_name2; JOIN查询: SELECT column_name(s) FROM table_name1 JOIN table_name2 ON table_name1.column_name = table_name2.column_name; 查询数据并限制数量: SELECT column_name(s) FROM table_name LIMIT num; 查询数据并跳过前几个数据: SELECT column_name(s) FROM table_name OFFSET num;
以上就是MySQL数据库SQL语句大全,其中包含了常用的增、删、改、查等操作语句。通过这些语句,大家可以很方便地对数据库进行管理和操作。