#使用cmd连接mysql
--连接数据库
mysql -uroot -p123456
-- 修改用户密码
update mysql.user set authentication_string=password('123456') where user='root' and Host = 'localhost';
-- 刷新权限
flush privileges;
-- 所有的sql语句都要用分号来进行结尾
-- 查看所有的数据库
show databases;
--切换数据库use数据库名
use shool;
Database changed;
-- 查看数据库中所有的表
show tables;
-- 显示数据库中所有表的信息
describe student;
-- 创建一个数据库
create database 数据库名;
--离开,退出连接
exit
-- 单行注释(SQL本来的注释)
-- 在SQLyog中可以使用#来表示单行注释
/* (SQL的多行注释)
hello
*/
创建数据库
create database [if not exists] hello;
删除数据库
drop database [if exists] hello
使用数据库
use `school`
查看数据库
show databases --查看所有的数据库
数据库列的操作
tinyint 十分小的数据 1个字节
smallint 较小的数据 2个字节
mediumint 中等大小的数据 3个字节
int 标准的整数 4个字节 常用的 int
bigint 较大的数据 8个字节
float 浮点数 4个字节
double 浮点数 8个字节(精度问题!)
decimal 字符串形式的浮点数 金融计算的时候,一般使用decimal