一、数据库相关操作1. 创建数据库create database 库名;2. 查看所有数据库show databases;3. 查看数据库详情show create database 库名;4. 使用数据库use 库名;5.删除数据库drop database 库名;二、表相关操作1. 创建表create table 表名(id int(10)not null unique primary key,name varchar(20) not null,sex varchar(4));2. 删除表drop table 表名;drop table 表名1,表名2;3. 查看有哪些表show tables;4. 查看表结构desc 表名;5. 在表里添加字段alter table 表名 add column 字段名 int(10) not null;6. 在表里修改字段名;alter table 表名 change 旧字段名 新字段名 新字段类型;7. 删除字段alter table 表名 drop 字段名;8. 复制表结构,并创建新的表create table 新表名 like 旧表名;9. 复制表结构及数据,并创建新表create table 新表名 as select * from 旧表名;10. 复制表结构中指定字段,并创建新的表create table 新表名 as select id,name,sex from 旧表名 where 1<>1;三、数据相关操作查询1. 查询表中所有数据select * from 表名;2.去重(distinct)select distinct 字段名 form 表名;3.列重命名select id as '编号', name '名称', sex '性别' from 表名;4. 排序(desc降序,asc升序)select * from 表名 order by 字段名 desc;select * from 表名 order by 字段名 asc;5.分组(可以和聚合函数一起使用:sum、count、max、min)select * from 表名 group by 字段名 ;select count(*) from 表名 group by 字段名;