操作数据库
create database if not exists NAME
drop database if exists NAME
use `NAME
show databases
数据库的列类型
数值(范围)
tinyint(十分小)1
smallint(较小)2
mediumint(中等大小)3
int(标准)4 常用
big(较大)8
float(浮点数)4
double(浮点数)8
decimal(字符串形式的浮点数)金融计算的时候,一般使用
字符串(长度)
char 0~255
varchar 0~65535 常用
tinytext 0~2^8-1
text 0~2^16
时间日期
java.util.Date
date YYYY-MM-DD日期格式
time HH: mm: ss时间格式
datetime YYYY-MM-DD 最常用的时间格式
timestamp 时间戳 1970.1.1到现在的毫秒数
year 年份表示
null
数据库的字段属性(重点)
Unsigned
无符号的整数
声明了该列不能声明为负数
zerofill
0填充的
不足的位数,使用0来填充
auto incr
自增
Null or not Null
notNull,如果不填写,就报错
Null,如果不填写,默认就是null
默认
设置默认值
id主键
'version'乐观锁
is_delete伪删除