DDL : 数据设计语言
DDL : 数据库操作
1 | -- 查询所有数据库 |
DDL : 表操作
创建
1 | -- 使用IDEA图形化工具 |
查询
1 | -- 查询当前数据库所有表 |
修改
1 | -- 修改表名 |
删除
1 | -- 删除表 |
DML : 数据操作语言
DML : 插入数据
1 | -- 1. 为tb_emp表的username, name, gender插入值 |
DML : 修改数据
1 | -- 1. 将ID为1的员工姓名修改为 ’张三‘ |
DML : 删除数据
1 | -- 1. 删除表中Id为1的员工 |
DQL : 数据查询语言
DQL : 基本查询
1 | -- 1. 查询指定字段name, entrydate 并返回 |
DQL : 条件查询
1 | -- 1. 查询 姓名 为 杨逍 的员工 |
DQL : 分组查询
聚合函数
1 | -- 聚合函数 : 不对null值进行运算 |
分组查询
1 | -- 1. 根据性别分组,统计男性和女性员工的数量 |
DQL : 排序查询
1 | -- 1. 根据 入职时间,对员工进行 升序排序 - 默认为升序排序 |
DQL : 分页查询
1 | -- 1. 从 起始索引0 开始查询员工信息,每页展示5条数据 |
多表查询
内连接
1 | -- 隐式内连接 |
1 | -- 1. 查询员工的姓名,及所属的部门名称(隐式内连接) |
外连接
1 | -- 1. 查询员工表 所有 员工的姓名, 相对应的部门名称(左外连接) |
子查询
1 | -- 示例 |