作业1
alter database zoo default character set gbk collate gbk_chinese_ci; #修改数据库zoo字符集为 gbk
create database zoo #创建zoo数据库
show create database zoo #查看创建数据库zoo信息
drop database zoo #删除数据库zoo
作业2
create database db_system; #创建数据库db_system
create table user( #创建user表
id int primary key auto_increment comment 'id',            # id      整形  主键,自增长  id
 
 NAME char(20) not null comment '姓名',                         #NAME   字符型 非空      姓名
 
 gender char(4) not null comment '性别',                          #gender   字符  非空      性别
 
 birthday date comment '生日',                                          #birthday 日期型         生日
 
 entry_date date not null comment '入职时间',                  #entry_date 日期型 非空      入职时间
 
 job char(30) not null comment '职位');                              #job    字符型 非空      职位
作业3
create table salary( #创建表salary
id int primary key auto_increment comment 'id', #id 整形 主键,自增长 id
userid int not null comment '用户id', #userId 整型 非空,外键,关联的是user 表的id字段 用户id
baseSalary double not null comment '基本工资', #baseSalary 小数 非空 基本工资
month int not null comment '月份', #month 整数 非空 月份
allowances double not null default'0.0' comment '补贴'); #allowances 小数 非空,默认为0 补贴
alter table salary add constraint fk_userid
foreign key(userid) references user(id);
 作业4
alter table user add image blob(255) ;
在上面员工表的基本上增加一个image列,类型是blob,长度255。
alter table user modify job char(60);
修改job列,使其长度为60。
alter table user drop gender;
删除gender列。
alter table salary rename usersalary ;
表名salary改为usersalary。
alter table user default character set utf8 collate utf8_unicode_ci;
修改表的字符集为utf8;
alter table user change name username char(20);
列名name修改为username