当前位置:网站首页>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)备份-此时服务可用
边栏推荐
- About yolo7 and gpu
- 自动化测试的成本高效果差,那么自动化测试的意义在哪呢?
- C Expert Programming Chapter 4 The Shocking Fact: Arrays and Pointers Are Not the Same 4.3 What is a Declaration and What is a Definition
- 力扣:70. 爬楼梯
- 想低成本保障软件安全?5大安全任务值得考虑
- MySQL date functions
- 去重的几种方式
- idea设置识别.sql文件类型以及其他文件类型
- 解决错误:npm WARN config global `--global`, `--local` are deprecated
- 动态规划总括
猜你喜欢
【问题解决】同一机器上Flask部署TensorRT报错记录
Cannot read properties of null (reading ‘insertBefore‘)
少年成就黑客,需要这些技能
部署LVS-DR群集【实验】
7.13 Day20----MYSQL
Typora 使用保姆级教程 | 看这一篇就够了 | 历史版本已被禁用
sql server如何得到本条记录与上一条记录的差异,即变动值
败给“MySQL”的第60天,我重振旗鼓,四面拿下蚂蚁金服offer
Can‘t connect to MySQL server on ‘localhost3306‘ (10061) 简洁明了的解决方法
Canal mysql data synchronization
随机推荐
关于yolo7和gpu
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.3 什么是声明,什么是定义
leetcode 12. Integer to Roman numeral
LCP 17. 速算机器人
MySQL log articles, binlog log of MySQL log, detailed explanation of binlog log
Resolved error: npm WARN config global `--global`, `--local` are deprecated
day13--postman interface test
Use Patroni callback script to bind VIP pit
一个对象引用的思考
BFC、IFC、GFC、FFC概念理解、布局规则、形成方法、用处浅析
4.1 声明式事务之JdbcTemplate
TensorRTx-YOLOv5工程解读(二)
梳理CamStyle、PTGAN、SPGAN、StarGAN
[Evaluation model] Topsis method (pros and cons distance method)
代码重构:面向单元测试
高性能高可靠性高扩展性分布式防火墙架构
想好了吗?
【论文阅读笔记】无监督行人重识别中的采样策略
3面头条,花7天整理了面试题和学习笔记,已正式入职半个月
What are the steps for how to develop a mall system APP?