创建一个数据库(不区分大小写) 字符集为utf8
create database if not exists db1 charset=utf8 collate utf8_general_ci;
创建一个数据库(区分大小写) 字符集为utf8
create database if not eixsts db2 character set utf8 collate utf8_bin;
使用数据库
use db1;
在该数据库下创建表
create table test1(
id pinyint primary key auto_increment comment '编号',
name varchar(20) comment '姓名',
);
查询表结构
desc test1;
在表中插入数据
insert into test1(name) values ('张三'),('李四');
修改表 给表添加字段
alter table test1 add gender enum('男','女') default '男' after name;
修改表名
alter table test1 rename to test;
修改表中某个字段名
alter table test change name xingming varchar(20);
删除表中某个字段
alter table test drop gender;
查表
select * from test;
删除表
drop table test;