数据库的基础知识

一、mysql简介

什么是mysql

二、mysql数据库入门基础知识

mysql的service的服务管理和登录

mysql的可视化图形界面操作和命令操作

三、mysql的库表深入解析

什么是库?

 

什么是表?

 

mysql的sql的各类语句精讲

操作语句分类

DDL数据定义语言 例如:建库、建表

DML数据操作语言 例如:对表中的数据进行增删改操作

DQL数据查询语言 例如:查询

DCL数据控制语言 例如:对用户的权限进行设置

 

 

1、mysql 核心知识之DDL数据定义语言

创建库

创建表

 

mysql创建表之常用的数据类型

数据类型定义:

mysql常见的数据类型

整数型

浮点数

定点型

字符串类型

时间型

mysql数据表必备知识之创建表

2、mysql核心知识之DML数据操作语言

insert into 表名(字段名) values (字段对应值);

insert into 表名 values (所有字段对应值)

一次性插入多个数据

insert into 表名(字段名)values (对应值1),(对应值2),(对应值3);

mysql 深入剖析表数据的修改以及删除

修改 

update 表名 set 字段名1=新值1 where 字段名=值;

update 表名 set 字段名1 =新值1,字段名2=新值2 where 字段名=值;

删除 

delete from 表名 where 字段名=值

delete  不会释放空间,不会删除定义 delete from 表名 

truncate  不会记录删除操作,恢复占用空间,不会删除定义  truncate table 表名

drop 会删除整张表 释放表占用的空间  drop table 表名

删除速度:drop > truncate >delete 

 

3、mysql核心知识之DQL数据查询语言与高级查询

基础查询

1.简单查询

select * from table;

2.精确查询

select * from table where 字段名=值;

3.模糊条件查询 

show table like '%aracter%';

4、范围查询

select * from table where 字段名 between 1000 and 2000;

select * from teble where 字段名 between '' and '';

5、离散查询

select * from where 字段名 in (值1,值2,值3);

6、清楚重复值查询

select  distinct from table;

7、统计查询(聚合函数)

count()或count(*)

select count(*) form table;

sum()计算总和

 max()计算最大值

select * from table where 字段名=(select max(字段名)from table);

avg()计算平均值

select avg(字段名)from table;

 min()计算最小值

select * from table where 字段名=(select max(字段名)from table);

concat 函数 起到链接作用

8、查询子句之group by 分组查询

select  字段名 ,count(*)from table group by 字段名;

9、查询子句之having 条件查询(筛选)

select  字段名 ,count(*)from table group by 字段名 having 字段名=值;

 10、查询子句之order by 排序查询(排序)

select * from table order by 字段名;

顺序 where  -----group by ---having ----order by

11、查询子句之limit 限制查询(限制)

select*  from table limit 4,5;

12、查询子句之exisit型子查询

select 1 from table where 1=1;

select * from table a where exists (select  1 from 表名2 where 条件) ;

13、查询值子句之左链接查询和右链接查询

左链接

右链接

select  a.table1 ,b.* from table1 left join table2 on a.table1=b.table2

select  a.table1 ,b.* from table1 right join table2 on a.table1=b.table2

 

 

14、查询子句之内链接查询和联合查询

内连接:

select a.table2 from table1 a inner join table2 on a.table1=b.table2

 

posted @ 2023-02-08 01:41  一路向北转南  阅读(11)  评论(0)    收藏  举报