一、数据库
1、显示:show database;
2、创建:create database `数据库名称` default charset utf8 collate utf8_general_ci;
3、使用:use 数据库名称;
4、删除:drop database 数据库名称;
5、退出:quit
二、数据表
1、显示:show tables;
2、创建:create table 表名称(列名 数据类型,列名 数据类型,......);
3、修改:alter table 表名 rename to 新表名:
4、删除:drop table 表名;
三、数据列
1、显示:desc 表名;
2、添加:alter table 表名 add 列名 数据类型......;
3、删除:alter table 表名 drop column 列名;
4、修改:
(1)列名:alter table 表名 change 原列名 to 新列名;
(2)属性:alter table 表名 modify 列名 (新)数据类型 是否为空 是否自增;
(3)主键:
alter table 表名 drop primary key;
alter table 表名 add primary key(列名);
(4)默认值:
alter table 表名 alter column 列名 drop default;
alter table 表名 alter column 列名 set default 默认值;
四、数据值
1、查看:select 列名 from 表名 where 条件;
2、添加:insert into 表名(列名1,列名2,...)values(值1,值2,...);
3、删除:delete from 表名 where 条件;
4、修改:update 表名 set 列名=赋值 where 条件;
5、清空:truncate table 表名;