整理不易
mysql -u用户名 -p密码 连接数据库
update mysql.user set authentication_string=password("123456") where user="root" and Host = "localhost"; (修改用户密码 注意中文!!)
flush privileges 刷新权限
show databases 查看有多少数据库
use wzh(数据库名) 切换数据库
show tables 查看数据库中所有的表
describe 表名 查看表中所有的数据
create database 数据库名 创建一个数据库
-- 是注释
exit 退出
create database [if not exists] 数据库名 如果数据库不存在则创建数据库
drop database [if exists] 数据库名 如果数据库存在就删除数据库
如果表名和字段名是一个特殊字符 就需要用 `特殊字符` 来表示
数据库类型
1、数值
tinyint 1字节
smallint 2字节
mediumint 3字节
int 4字节
bigint 8字节
float 4字节
double 8字节(精度会有问题)
decimal 字符串形式的浮点数 金融计算的时候一般用decimal
2、字符串
char 0~255
varchar 0~65535 可变字符串
tinytext 微文本 2^8-1
text 文本串2^16 -1
3、时间日期
data YYYY-MM-DD日期格式
time HH: mm: ss 时间格式
datatime YYYY-MM-DD HH: mm: ss 最常用的时间格式
timestamp 时间戳 1970.1.1到现在的毫秒数
year 表示年份
4、null
没有值,未知
注意不要实用NULL进行运算,结果为NULL