当前位置:网站首页>MySql的DDL和DML和DQL的基本语法
MySql的DDL和DML和DQL的基本语法
2022-07-24 03:17:00 【随性.533】
SQL 中最重要的 DDL 语句:
CREATE DATABASE - 创建新数据库
ALTER DATABASE - 修改数据库
CREATE TABLE - 创建新表
ALTER TABLE - 变更(改变)数据库表
DROP TABLE - 删除表
CREATE INDEX - 创建索引(搜索键)
DROP INDEX - 删除索引

SQL语句的DML 部分:
SELECT - 从数据库表中获取数据
UPDATE - 更新数据库表中的数据
DELETE - 从数据库表中删除数据
INSERT INTO - 向数据库表中插入数据

SQL的DQL的基本语法
| select+字段列表 | 基本查询 |
| from+表名列表 | 基本查询 |
| where+条件列表 | 条件查询 |
| group by+分组字段列表 | 分组查询 |
| having+分组后条件列表 | 分组查询 |
| order by+排序字段列表 | 排序查询 |
| limt+分页参数 | 分页查询 |

-- 分页
select *from student limit 2,3; -- 公式 (页码-1)*步长 -- 外联查询
-- left join on 左外联
-- right join on 右外联
select *from student left join class on student.classid= class.classid;-- 左外联
union
select *from student right join class on student.classid=class.classid; -- 右外联
use myschool;
group by 分组
select student.sid,sname,avg(score) a from student,sc where student.sid=sc.sid
group by sid having a>=60
like % 模糊查询
select count(*) from teacher where tname like '李%'
desc 降序
检索” 01 “课程分数小于 60,按分数降序排列的学生信息
select * from sc left join student on sc.sid = student.sid where score < 60 and cid = 1 order by score desc
边栏推荐
- JS 數組 isAarray() typeof
- Bingbing learning notes: basic operation of vim tool
- uva11389
- [MySQL learning] install and use multiple versions of MySQL, MySQL 8 and MySQL 5.7 at the same time, compressed version
- JIRA automation experience sharing for 2 years
- MySQL sub database and sub table and its smooth expansion scheme
- C自定义类型详解
- Lcd1602——斌哥51
- Tweenmax+svg Pikachu transformation ball
- C动态内存管理详解
猜你喜欢

AcWing 4498. 指针 (DFS)

在openEuler社区开源的Embedded SIG,来聊聊它的多 OS 混合部署框架

String.split() the most detailed source code interpretation and precautions

Ugui source code analysis - Mask

Customize the default width and height of kindeditor rich text

OSPF comprehensive experimental configuration

IDEA Clone的项目报Cannot resolve symbol ‘Override‘

openEuler 资源利用率提升之道 01:概论

Tweenmax+svg Pikachu transformation ball

Take you into the world of MySQL mvcc
随机推荐
The simple use of ADB command combined with monkey is super detailed
About Aries framework addition, deletion, modification and query - query demo
In the future, when the interviewer asks why you don't recommend using select *, please answer him loudly!
Skywalking distributed system application performance monitoring tool - upper
Keras deep learning practice (15) -- realize Yolo target detection from scratch
Summernote font displays Chinese
B. Eastern Exhibition- Codeforces Round #703 (Div. 2)
WPS前骨干历时10年打造新型软件,Excel用户:我为此改用WPS
FTP服務與配置
JS array isaarray() typeof
The first edition of Niuke brush question series (automorphic number, return the number of prime numbers less than N, and the first character only appears once)
Hcip day 9 notes (OSPF routing feedback, routing policy, and Configuration Guide)
MariaDB related instructions
Ue5 split screen (small map) solution
Summernote supports custom video upload function
SSM based blog system [with background management]
AcWing 4498. 指针 (DFS)
JS small game running bear and cat source code
How will you answer the "Hello world" challenge written in C language?
JVM initial