当前位置:网站首页>7.13 Day20----MYSQL
7.13 Day20----MYSQL
2022-08-04 05:34:00 【Which cookie are you?】
目录
3. SQL分类-语法整理(Sort in order of importance)
6. Four characteristics and four isolation levels of things:
一、MYSQL-重点
1. 数据类型:
问题:
1.float和double的区别:
float 4个字节 单精度
double 8个字节 双精度
2.char和varchar的区别:
charThe supported lengths are 0-255.varcharThe supported lengths are 0-65535
char是定长字符串,string with space;varcharis the length is variable,以时间换空间;charThe data length is not recorded dynamically,varcharThe data length is recorded dynamically,varchar的性能没有char好,因为varcharSave more dynamic space
3.char(32)和varchar(32)括号里面的长度是字节还是字符:
Mysql5.0Versions used to be bytes,假设字符集是UTF-8,一个中文3个字节那么char(32)只能存储10个中文字符
4.What type to store the amount in:
It is strictly forbidden in the databasefloat和doubleThere are two solutions for storing the amount:第一个,use fixed-point typedecimal存储金额,第二个方案,Use the long integer type to store the amount to the smallest unit
5.超长文本(博客,文章)怎么存储:
严禁使用varchar存储超长文本(超过5000),应该改用Blobl类型或者Testtype to store very long text,And the fields of super long text should be separated out,Associate with the main table,Prevent the super-long field in the super-long text from affecting the query efficiency of the main table
6.二进制文件(图片、音频、视频)怎么存储:
MYSQLThe database can store binary filesBinary类型,但是性能非常差,Store binary data in a file,Then record the path of the file in the database
7.MYSQL的整型支持无符号,使用关键字UNSIGNED
age tinyint --ageThe value range of the field is-128到127
age tinyint unsigned --ageThe value range of the field is0-255
2. 约束
1.非空约束
NOT NULL: 用于控制字段的内容一定不能为空(NULL).
2.唯一约束 (Unique indexes are added automatically)
UNIQUE: 控件字段内容不能重复,一个表允许有多个 Unique 约束.
3.主键约束 (Clustered indexes are added automatically)
PRIMARY KEY: 也是用于控件字段内容不能重复,但它在一个表只允许出现一个.
4.外键约束
FOREIGN KEY: 用于预防破坏表之间连接的动作,也能防止非法数据插入外键列,因为它必须是它指向的那个表中的值之一.
5.检测约束 (MySQLThe database has no check constraints)
CHECK: 用于控制字段的值范围.
3. SQL分类-语法整理(Sort in order of importance)
1.数据查询语言DQL(Data Query Language)
SELECT,FROM,WHERE,GROUP BY,ORDER BY
这个较为好理解 即查询操作,以select关键字.各种简单查询,连接查询等 都属于DQL.
2.数据操纵语言DML(Data Manipulation Language)
INSERT,UPDATE,DELETE
主要为以上操作 即对数据进行操作的,对应上面所说的查询操作 DQL与DML共同构建了多数初级程序员常用的增删改查操作.而查询是较为特殊的一种 被划分到DQL中.
3.事务控制功能TCL(Transaction Control Language)
COMMIT,ROLLBACK
用于操作事务,以及事务的提交和回滚操作
4.数据定义语言DDL(Data Ddefinition Language)
CREATE,DROP,ALTER
主要为以上操作 即对逻辑结构等有操作的,其中包括表结构,视图和索引.
5.数据控制功能DCL(Data Control Language)
GRANT,REVOKE
It is mainly used to grant or revoke certain permissions to database users to access the database
4.连表查询的方式:
5. 关系类型和三范式、反三范式:
数据库表关系:一对一,一对多(多对一),多对多
三范式-Change space at a time(增加关系来减少冗余数据)
反(打破)三范式-以空间换时间(允许适量的冗余数据,减少关系)
(1)第一范式(1NF)
数据库的每一列都是不可分割的基本数据项,It is not possible to have multiple values in the same column,即:An attribute of an entity class cannot have multiple values or duplicate attributes(原子性)
(2)第二范式(2NF)
The premise is to satisfy the first normal form,It is required that each instance or row in the database table must be uniquely distinguishable,To achieve the distinction usually requires adding a column to the table,以存储各个实例的唯一标识(不产生局部依赖,Each column is completely dependent on the primary key,一张表只描述一件事)
(3)第三范式(3NF)
The premise is that the second normal form is satisfied,A database table is required to not contain non-primary key information that is already contained in other tables(It is to use foreign keys to associate them,不产生传递依赖,All columns are directly dependent on the primary key,Also use foreign key associations,Foreign keys are derived from the primary keys of other tables)
(4)反三范式
The anti-three paradigms are in pursuit of performance,因为3NFThe proposed purpose is to reduce redundancy,减少不必要的存储,However, with the price reduction of storage devices and the continuous improvement of people's performance requirements,Put forward the concept of anti-three paradigms
6. Four characteristics and four isolation levels of things:
7.锁的种类:
8.死锁、如何防止死锁:
9.索引:
二、MSQL-了解
1.存储引擎的区别:
InnoDb
Mylsam
Memory
2.关系型数据库与NoSQL(非关系型)数据库的区别:
主流的关系型数据库:MySQL Oracle
主流的NoSQL数据库:Redis
MySQL和Redis的关系不是谁能替代谁,而是在数据量非常大,数据库并发操作非常频繁的情况下,可以通过RedisTo build a cache server to shareMySQL的压力
3. 视图、存储过程、存储函数、触发器
4.SQL语句优化、数据库优化的思路:
5.数据库的冷热备份:
冷备份-停机(关闭数据库服务)后备份-此时服务不可用
热备份-不停机(Do not shut down the database service)备份-此时服务可用
边栏推荐
- C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.2 我的代码为什么无法运行
- 在被面试官说了无数次后,终于潜下心来整理了一下JVM的类加载器
- Cannot read properties of null (reading 'insertBefore')
- MySQL日期函数
- 【云原生--Kubernetes】Pod资源管理与探针检测
- TensorRTx-YOLOv5工程解读(二)
- 擎朗智能全国研发创新中心落地光谷:去年曾获2亿美元融资
- LCP 17. 速算机器人
- [Cloud Native--Kubernetes] Pod Resource Management and Probe Detection
- Redis common interview questions
猜你喜欢
Tactile intelligent sharing - SSD20X realizes upgrade display progress bar
Programming hodgepodge (4)
嵌入式系统驱动初级【4】——字符设备驱动基础下_并发控制
【一步到位】Jenkins的安装、部署、启动(完整教程)
npm报错Beginning October 4, 2021, all connections to the npm registry - including for package installa
Get the selected content of the radio box
Performance testing with Loadrunner
8、自定义映射resultMap
7.13 Day20----MYSQL
《看见新力量》第四期免费下载!走进十五位科技创业者的精彩故事
随机推荐
OpenSSF 安全计划:SBOM 将驱动软件供应链安全
Towards Real-Time Multi-Object Tracking (JDE)
The difference between px, em, and rem
How to view sql execution plan offline collection
Do you think border-radius is just rounded corners?【Various angles】
9、动态SQL
部署LVS-DR群集【实验】
4.3 基于注解的声明式事务和基于XML的声明式事务
动态规划总括
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.3 什么是声明,什么是定义
力扣:343. 整数拆分
擎朗智能全国研发创新中心落地光谷:去年曾获2亿美元融资
字节最爱问的智力题,你会几道?
C Expert Programming Chapter 5 Thinking about Chaining 5.6 Take it easy --- see who's talking: take the Turning quiz
px、em、rem的区别
Canal mysql data synchronization
The 2022 PMP exam has been delayed, should we be happy or worried?
SLSA 框架与软件供应链安全防护
DataTable使用Linq进行分组汇总,将Linq结果集转化为DataTable
C专家编程 第5章 对链接的思考 5.3 函数库链接的5个特殊秘密