当前位置:网站首页>Related concepts of several databases
Related concepts of several databases
2022-07-28 11:06:00 【hongdi】
database : Used to store relational data sets in a specific format
file : Used to store tables composed of data
Filegroups : Used to organize multiple files for management
framework : Used to manage the naming of objects such as data tables
snapshot : A quick restore point for building databases , Convenient for testing and fault recovery
Database file composition :
Master data file : The default extension is .mdf
Auxiliary data file : The default extension is .ndf( A database can create multiple .ndf file )
Transaction log file : The default extension is .ldf( Record all operations on the database , But it doesn't contain the data being manipulated )
The default location for all data files and log files is C:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data( among n Is to identify the installed SQL Server Instance name _ Instance name )
Be careful : All data and objects should be stored in .ndf In file , and .mdf The file is only responsible for storing the data directory , This can effectively avoid disk contention during access .
SQL SERVER Two storage structures of :
page : A contiguous block of disk space used for data storage , size 8KB, The beginning of each page is 96 Byte header , Used to store system information about the page , Including page numbers 、 Page type 、 The available space of the page and the allocation unit of the object that owns the page ID
Section :8 Consecutive physical pages , size 64KB
( A smaller watch (<64KB) Share an interval with other database objects )
characteristic :
Rows cannot span pages : The maximum amount of data and overhead in a single row of a page is 8,060 byte (8 KB).
( Two exceptions :1: about varchar、nvarchar、varbinary、sql_variant or CLR Columns of user-defined types , The length of a single column must still be 8000 byte (8060-96<8000B) Within the limits of . Only their combined length can exceed that of the table 8060 Byte row limit .2: When the total row size of all fixed and variable columns in the table exceeds the limit 8,060 Byte time ,SQL Server One or more variable length columns will be dynamically moved from the maximum length column to ROW_OVERFLOW_DATA Pages in allocation units . Whenever an insert or update operation increases the total size of a row to more than the limit 8,060 Byte time , This will be done . Move the column to ROW_OVERFLOW_DATA After the page in the allocation unit , Will be in IN_ROW_DATA Maintain on the original page in the allocation unit 24 Byte pointer . If subsequent operations reduce the size of the row ,SQL Server The columns are dynamically moved back to the original data page .)
Tables and indexes are stored in intervals
SQL Server The information of each database in is recorded in master Database sysdatabases and sysaltfiles In the table .
“ Sort rule ” It refers to the sorting order principle of data , It is used to determine the specific position of the data value when sorting data . Different rules sort data in different order , This depends on whether the collation is case sensitive 、 Sorting rules of special characters, etc .
Describe the characteristics of transactions ACID:
Atomicity (Atomictity). All operations defined in the transaction are either completed , Or don't finish it all .
Uniformity (Consistency). Transactions always keep data in a consistent state
Isolation, (Isolation). The transaction runtime is isolated from other database activities ; Other concurrent database activities have no impact on this transaction .
persistence (Durability). When the transaction is committed , The results will be stored in a persistent storage facility , And it still exists after the system failure .
Execute single SQL sentence , It's actually SQLServer Secretly use transactions to complete —— Implicit transaction . If multiple statements are executed as a unit, the transaction used is called —— Explicit transaction .
SQL Server When performing disk modification , And before these changes are written to the database , Record them in the log .
step :
1、 The application program issues data modification instructions
2、 When performing a modification , Find out whether the cache has data pages affected by modification , If it does not exist, these pages will be loaded from the disk into the buffer and modified , If it exists, modify it directly .
3、 When making changes , The log will record every statement that modifies the data ( Any changes should be recorded in the log before being modified in the database , And write to disk . This type of log becomes a pre write log )
4、[ Checkpoint process ] Recursively , Will all [ Data in completed transaction ] Write to the database on disk
5、 If the system fails , be [ Automatic recovery process ] Transaction logs will be used [ Roll forward ] All submitted things , And rollback any outstanding transactions .
Transaction logs are used during automatic recovery [ Thing marker ]( Such as :begin transaction...commit transaction) To determine the beginning and end of things . The data will also be in [ Checkpoint process ] Start writing to disk .
To improve performance , It is recommended to place the transaction log file on a physical disk separate from the data file . This will reduce disk contention , And can make a group of drive heads in [ Other heads read data from data files ] At the same time , Log transactions to the transaction log . Because transactions can be written to disk immediately , There is no need to wait for the data reading operation to complete , Therefore, the speed of updating data will be very fast . At the same time, because the log files are written in sequence , So if the log is stored on a dedicated disk , The disk head will remain in the correct position for the next write operation , Instead of wasting time moving the head again , therefore , It can improve the speed of writing transaction logs .
边栏推荐
- Why is low code (apaas) popular again recently?
- Blue Bridge Cup embedded Hal library USART_ TX
- 几个数据库的相关概念
- 读懂这6本书,学习MySQL更轻松
- Stacks and queues
- 盘点:6本书教会你职场晋升必备技能
- platform驱动平台下,关于probe函数中,形参dev的“dev->dev.of_node;”的理解
- 1. Sum of two numbers
- Problems needing attention when VC links static libraries
- JS - 修改数组中对象的键名
猜你喜欢

做数据分析,你还不懂RFM分析方法(模型)?

MySQL Architecture Principle

I use the applet container to improve the efficiency of mobile R & D by 5 times!

用 ZEGO Avatar 做一个虚拟人|虚拟主播直播解决方案

Inventory: 6 books teach you the necessary skills for career promotion

Ten questions about low code: tell everything about low code!

为什么传输前要进行编码与调制

Purchase, sale and inventory software suitable for small and medium-sized enterprises to solve five major problems

6. MapReduce custom partition implementation

Sword finger offer 35. replication of complex linked list
随机推荐
ThinkPad指纹验证在win7无法使用的解决方法
剑指 Offer 30. 包含min函数的栈
Nodejs:mongodb 简单模糊+分页查询实例
Sword finger offer 30. stack containing min function
Question of hanging the interviewer
Blue Bridge Cup embedded Hal library ADC
Blue Bridge Cup embedded Hal library USART_ TX
GKCheckerboardNoiseSource
Problems needing attention when VC links static libraries
Zero code | easily realize data warehouse modeling and build Bi Kanban
零代码 | 轻松实现数据仓库建模,搭建BI看板
samba学习
数组相关的知识点
JSON preliminary understanding
几个数据库的相关概念
offsetof宏与container_of宏分析详解
21. Merge two ordered linked lists
MySQL Architecture Principle
Table data processing software, what else besides excel?
Software designers ask 20 questions before the exam, pay attention!!