这是创建一个表,请问有人知道各字段名的意思吗?
create table blog(
blog_id bigint auto_increment comment '博客id' primary key ,
user_id bigint null default 0 comment '用户id',
blog_total varchar(100) default '' null comment '博客标题',
create_content text null comment '博客内容',
create_time timestamp default current_timestamp null comment '创建时间',
update_time timestamp default current_timestamp null on update current_timestamp comment '更新时间'
)charset=utf8;
我对这段命令的理解是:
创建blog这个表, '博客id '这个属性是主码。
其余'用户id','博客标题','博客内容','创建时间','更新时间'是其他属性名。
blog_id、user_id、 blog_total、create_content、create_time、update_time是字段名,
bigint、varchar、text是字段类型,和int类似
charset=utf8是建表语句,是为了不报错不乱码。
不知道我理解对不对,请指正。
create table blog(
//字段名称为blog_id,类型为长整形,auto_increment的作用是自动增长,从1开始累加,primary key是设置这个字段为主键,唯一
blog_id bigint auto_increment comment '博客id' primary key ,
//字段名称user_id 长整形,默认值为0,comment里面的内容是注释,可有可无
user_id bigint null default 0 comment '用户id',
//字段名称blog_total,字符串类型,最多允许100个字符,默认值为空
blog_total varchar(100) default '' null comment '博客标题',
//字段名称create_content,text文本类型,可以保存大文件的内容,最多可以几个G的数据
create_content text null comment '博客内容',
//字段名称create_time,类型为时间戳,默认获取系统当前时间
create_time timestamp default current_timestamp null comment '创建时间',
update_time timestamp default current_timestamp null on update current_timestamp comment '更新时间'
//表使用的字符集是utf8
)charset=utf8;
t comment '博客id' -------------注解
primary key -------------------主键
auto_increment --------------自增
charset=utf8------------------转中文
default-------------默认
你说的基本上都对