字符集
一般创建数据库或者表时要指定其字符集。插入表的内容会采用就近原则(MySQL默认字符集、数据库字符集、表的字符集)。
MySQL数据类型
- 整型 :十进制 十六进制 八进制
- 浮点数
- 字符串型 :“zoujidi”、“”由0个或多个字符串组成的数据
- null:不确定的值
整型
- tinyint 1字节 -128~127(有符号范围) 0~255(无符号范围) 小整数(用途)
- smallint 2字节 -32768~32767
- mediumint
- int
- bigint
unsigned 用于定义无符号类型,即非负整型
浮点数类型
float 单精度 4字节
- double双精度 8字节 (decimal(M,N)M表示显示长度N表示小数长度)
select if(sex,"男生","女生") as stusex,sname from student;
alert table student add birthday date;
update student set birthday="1995/10/08" where id=1;
select * from student order by id desc(asc) limit 2;
select distinct year(birthday) as "学生出生年份" from student;