代码改变世界

mysql 正则

2018-08-27 19:26 by 冻奶香甜玉米片, 191 阅读, 0 推荐, 收藏, 编辑
摘要:#正则表达式select * from employee where name like 'jin%';select * from employee where name regexp '^jin';select * from employee where name regexp '^jin.*(g 阅读全文

where优先级

2018-08-27 15:58 by 冻奶香甜玉米片, 336 阅读, 0 推荐, 收藏, 编辑
摘要:select name from emply where id >5; 先找表from emply 再找条件 where id >5 最后打印 你想打印的字段 可以把select看成打印 优先级为from->where-->select 先找到表,然后where一条条数据过滤,发现符合的就扔给sel 阅读全文

简单查询,最基本的

2018-08-27 15:49 by 冻奶香甜玉米片, 163 阅读, 0 推荐, 收藏, 编辑
摘要:#简单查询 SELECT id,name,sex,age,hire_date,post,post_comment,salary,office,depart_id FROM employee; SELECT * FROM employee; SELECT name,salary FROM employ 阅读全文

foreign key 多对一 多对对 一对一

2018-08-27 15:09 by 冻奶香甜玉米片, 348 阅读, 0 推荐, 收藏, 编辑
摘要:使用foreign key 要清除先有哪张表再有哪张表,后表对应前表 例如现有部门再有员工,所以员工对应部门 现有作者后有书,所以书对应作者 现有潜在顾客后有顾客,所以顾客对应潜在顾客 多对多建立3张表 全部都是使用foreign key 阅读全文

foreign key

2018-08-27 11:49 by 冻奶香甜玉米片, 369 阅读, 0 推荐, 收藏, 编辑
摘要:foreign key:建立表之间的关系 #1、建立表关系: #先建被关联的表,并且保证被关联的字段唯一 create table dep( id int primary key, name char(16), comment char(50) ); #再建立关联的表 create table em 阅读全文

auto_increment 自增长

2018-08-27 11:11 by 冻奶香甜玉米片, 812 阅读, 0 推荐, 收藏, 编辑
摘要:auto_increment create table t20( id int primary key auto_increment, (自增长必须为键) name char(16)); insert into t20(name) values('egon'),('alex'),('wxx'); i 阅读全文

primary key

2018-08-26 21:43 by 冻奶香甜玉米片, 375 阅读, 0 推荐, 收藏, 编辑
摘要:只要使用innodb就要为表指定主键; 如果不指定mysql就会自己找不为空且为一的作为主键,如果找不到,就会使用默认的(软件自己预定好的)作为主键; 主键分为单列主键和复合主键,用法和单列唯一,联合唯一一样; copy from oldboy egon; # 单列主键create table t1 阅读全文

mysql unique key

2018-08-26 20:01 by 冻奶香甜玉米片, 170 阅读, 0 推荐, 收藏, 编辑
摘要:create table b1(id int,name char unique)这样name字段就唯一了 或者create table b1(id int,name char,unique(id),unique(name))这种写法也行 这两种就是单列唯一 create table b1(id in 阅读全文

not full 和 default

2018-08-26 18:07 by 冻奶香甜玉米片, 351 阅读, 0 推荐, 收藏, 编辑
摘要:create table t16( id int, name char(6), sex enum('male','female') not null default 'male'); insert into t16(id,name) values(1,'egon'); 如果设置了不能传空而传空,则会 阅读全文

mysql枚举和集合

2018-08-26 17:52 by 冻奶香甜玉米片, 240 阅读, 0 推荐, 收藏, 编辑
摘要:create table consumer( id int, name char(16), sex enum('male','female','other'), level enum('vip1','vip2','vip3'), hobbies set('play','music','read',' 阅读全文
上一页 1 2 3 4 5 6 7 8 9 10 ··· 13 下一页