笔记之MySQL创建表create

创建表
要求:创建一个教师表teacher,身高保留两位小数
drop table if exists teacher;                                      (如果存在一个表teacher,删除它;这是避免表名已经存在无法创建新表)


create table teacher(                                                (创建一个教师表,表名是teacher)


id int unsigned primary key auto_increment,            (字段id,int unsigned两个单词连起来意思是无符号范围的整数,primary key主键,auto_increment递增)


name varchar(5),                                                      (字段name,varchar行:字段name,varchar(5)字符串5位)


age tinyint unsigned,                                                (字段age,tinyint unsigned ,意思是无符号整数,这个范围是(0~255))


heihgt decimal(5,2)                                                   (字段heihgt,decimal(5,2),解析 总共五位数,小数2位,整数3位)
)

需要了解整型、无符号范围、主键、字符串等数据类型

需要数据可以自己插入(insert into)下面是完整的创建表格的框架:

drop table if exists teacher;
create table teacher(
id int unsigned primary key auto_increment,
name varchar(5),
age tinyint unsigned,
heihgt decimal(5,2)
)

posted @ 2020-04-17 08:30  吾言!  阅读(563)  评论(0编辑  收藏  举报