MYSQL表内操作(1)
1.创建表:
create table tb5(id int not null auto_increment primary key,name varchar(16) not null,email varchar(32) null,age int default 3)default charset=utf8;
注:primary key --设为主键
outo_increment --设为自增
not null --不能为空
default --设置默认值
2.新增列:
alter table 表名 add 列名 类型 not null primary key auto_increment;
3.删除列:
alter table 表名 drop 表名 drop column 列名;
4.修改列类型:
alter table 表名 change 原列名 新列名 信类型;
5修改列默认值:
alter table 表名 alter 列名 set default 100;
6.删除列默认
alter table 表名 alter 列名 drop default;
7.添加主键:
alter table 表名 add primary key 列名;
8.删除主键:
alter table 表名 drop primary key;
9.查看表中内容:
desc tb7

浙公网安备 33010602011771号