MySQL
建库:
create database 库名::如create database student;
建表案例:
CREATE TABLE `staff` (
`id` int(6) NOT NULL AUTO_INCREMENT,
`name` char(25) NOT NULL,
`sex` int(2) NOT NULL,
`age` int(3) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
注意:
engine::表的搜索引擎;
charset::设置表的字符集;
primary key ():设置表的主键:
auto_increment:设置自增字段 ;
字段设计简述:
价格: 字符类型设计为 decimal(10,2); 10为十进制,2保留两位小数
表字段的添加
alter table staff add column post decimal(10,2) not null after age
注:: staff:表名
post:添加的新字段
decimal(10,2) 添加的字段类型
after age:添加在那个字段后面
表字段删除
alter table staff drop column post