Mysql复习秘籍
来源:互联网 发布:晨曦造价软件 编辑:程序博客网 时间:2024/06/05 00:27
#基础知识
1. 数据库的连接
mysql -u rootgod -p root -h 127.0.01
2. 库 知识
- show database
- use datebase
- create datebase dbname charset utf-8
- drop datebase dbname
3. 表操作
- show tables
- desc tableName (查看表结构)
- show create table tablename
- create table user(
id int auto_increment,
name varchar(20) not null default ”,
age tinyint unsigned not null default 0,
index id(id)
)engine=innodb charset=utf8;
- alter table tablename add 列名称1 列类型[列参数][not null default]
- alter table tablename change 旧列名 新列名[列参数][not null default]
- alter table tablename drop 列名
- alter table tablename add primary key 列名
- alter table tablename drop primary key 列名
- alter table tablename add unique|fulltext index 索引名
- alter table tablename drop index 索引名
- truncate table
4. 列类型讲解
- tinyint
- smallint
- mediumint
- int
- bigint
- float、double
- char (m) 定长、varchar(m) 变长、text
- text
- year
- date
- time
- datetime
- timestamp (不用赋值,改列会自己赋当前的具体时间)
5. 增删改查基本操作
- insert into 表(col1,col2,…)values(val1,val2,…)
- insert into 表 values(,,,);
- insert into 表
(,,,),
(,,,)
- update 表 set col1=val1,col2=val2,… where 条件;
- delete from 表 where 条件
- 条件查询:
1. 条件表达式的意义,表达式为真,则该行取出
2. 比较运算符=,!=,<><=>=
3. like,not like,in,not,between and
4. is null,is not null
- group by 使用的max、min、sum、avg、count
- having
- order by
- limit
- 连接查询
- 左连接 left join on
- 右连接 right join on
- 内连接 inner join
左右连接都是以在左边的表的数据为准,沿着左表查右表。
内连接是以两张表都有的共同部分数据为准备,也就是左右连接的数据之交集。
7. 子查询
- where型子查询
- from型子查询
8. 字符集
- mysql经典复习秘籍
- mysql复习秘籍
- MYSQL复习秘籍
- MySQL复习秘籍
- MySQL复习秘籍
- Mysql复习秘籍
- Mysql复习秘籍(燕十八出品)
- mysql之学习秘籍
- 燕十八MySQL-秘籍
- mysql复习
- MySql复习
- 复习MYSQL
- Mysql复习
- Mysql复习
- 复习MYSQL
- mysql复习
- 复习MySQL
- mysql复习
- 11/12训练日记 数位dp专题结束
- NOIP2017 睡觉记
- Spring IOC知识点总结
- 1305 Pairwise Sum and Divide
- sdnu 1099 前缀判断
- Mysql复习秘籍
- python基础-13-PyCharm工具常见问题
- 九.ARM裸机学习之串口通信详解1(串口通信接口及原理框图详解)
- 一个java写的贪心算法实现删数问题
- 通过修改Host文件访问dl.google.com下载更新AndroidSDK
- Theatre Square
- Spring 知识点提炼
- “精通”的代价--C++后端开发知识点
- this.close和this.hide --C#