更新上篇未总结完的知识点:
查看字符集:
show character set;
设置字符集:
set names 字符集;
查看校对集:
show collation;
数据库四大类型: 整数 小数 字符串 时间日期
迷你整型:
tinyint 1个字节
smallint 2个字节
mediumint 3个字节
标准整型:
int 4个字节
bigint 8个字节
小数型:
decimal float double
字符串类型:
text/blob 用于储存较大的文本
主键: primary key
特点:不允许重复出现内容
删除主键:
alter table 表名 drop primary key;
添加主键:
alter table 表名 add primary key(字段名);
自动增长: auto_increment
唯一键:unique key
删除唯一键:
alter table 表名 drop index 字段名;
描述字段: comment
create table t_comment ( in int primary key auto_increment comment '主键,自动增长', name varchar(20) not null comment '学生名字' );查看comment 的结果:
show create table 表名;

这篇博客介绍了数据库的基础知识,包括字符集、校对集的查看与设置,以及数据库的四大类型:整数、小数、字符串和时间日期。讲解了不同类型的整数如tinyint、smallint到bigint,小数型如decimal、float和double,以及字符串类型的text和blob。此外,还阐述了主键和唯一键的概念,如何添加和删除,并展示了创建带有注释的表的示例。

被折叠的 条评论
为什么被折叠?



