摘要:
测试类代码:(省去了接口和实现类) 阅读全文
摘要:
select ... from 表名 where ... group by ... having ... order by ... limit ...; select ... from A left/right join B on ... where ...; 阅读全文
摘要:
SQL分类 DDL数据定义语言 包括:create alter drop truncate 不支持事务 DML数据操作语言 包括:insert delete update select 支持事务 DQL数据查询语言 包括:select TCL事务控制语言 包括:begin; commit; roll 阅读全文
摘要:
MySQL共有5个约束 1 主键约束 primary key(id) 2 外键约束 3 唯一约束 unique 4 非空约束 not null 5 默认约束 default 其他: auto_increment 值自动增加,通常配合主键约束使用 comment 表字段的注释,创建表时在字段后使用 a 阅读全文
摘要:
外键:用于建立关系的字段称为外键 1对1关系 有AB两张表,A表中一条数据对应B表中一条数据,同时B表中一条数据也对应A表中的一条数据 应用场景:为了提高查询效率,把原有的一张表查分成两张表,如:商品表和商品详情表,用户表和用户信息扩展表 1对多关系 有AB两张表,A表中一条数据对应B表中多条数据, 阅读全文
摘要:
将数据库查询单独开来是因为使用最多,也是技巧最多,同时面试最容易问的部分 简单查询 select * from table_name; select name,age from table_name; 模糊查询%和_ %表示0个或多个未知字符 _表示单个未知字符 select name,age fr 阅读全文
摘要:
插入数据 insert into table_name values('value1','value2','value3',....); 值的数量和顺序必须要和表字段的数量和顺序保持一致 指定字段插入 insert into table_name(字段1名,字段2名...) values('valu 阅读全文
摘要:
新建一个数据库 create database database_name character set utf8; 创建一个表 create table table_name(字段名 类型...) charset=utf8; 查看当前数据库 show databases; 使用一个数据库 use d 阅读全文
摘要:
执行systemctl start mariadb.service后终端控制台报如下错误: Job for mariadb.service failed because the control process exited with error code. See “systemctl status 阅读全文
摘要:
进入数据库执行 SET GLOBAL character_set_client=utf8;SET GLOBAL character_set_connection=utf8;SET GLOBAL character_set_database=utf8;SET GLOBAL character_set_ 阅读全文