数据库常用命令
创建数据库表的常用命令
create table 数据表(
列名1 数据类型 【约束】【comment 注释】
列名2 数据类型 【约束】【comment 注释】
)
USE test;
create TABLE student(
id int unsigned not null primary key,
name varchar(20) not null,
sex char(1) not null,
birthday date not null,
tel char(11) not null,
remark varchar(200)
);
添加字段
alter table 数据表(
add 列名1 数据类型 【约束】【comment 注释】
add 列名2 数据类型 【约束】【comment 注释】
)
修改字段
alter table 数据表(
modify 列名1 数据类型 【约束】【comment 注释】
modify 列名2 数据类型 【约束】【comment 注释】
)
修改字段名
alter table 数据表(
change 列名1 新列明1 数据类型 【约束】【comment 注释】
change 列名2 新列明2 数据类型 【约束】【comment 注释】
)
删除字段
alter table 数据表(
drop 列名1 ,
drop 列名2
)