SQL Server管理 这些你懂吗?
SQL Server管理,你做得好吗?下文这些可能会对你的工作有一些帮助,不妨耐心的看看吧。 1. 数据库文件有.mdf .ndf .ldf三种文件,mfd为主数据库文件,ndf为从数据库文件,ldf为日志数据库文件,每个数据库mdf文件只有一个,ndf文件可以有多个。 2. 数据页大
SQL Server管理,你做得好吗?下文这些可能会对你的工作有一些帮助,不妨耐心的看看吧。
1. 数据库文件有.mdf .ndf .ldf三种文件,mfd为主数据库文件,ndf为从数据库文件,ldf为日志数据库文件,每个数据库mdf文件只有一个,ndf文件可以有多个。
2. 数据页大小为8k,sql数据库最大一个特性是数据无跨页,比如一条数据3k,那么5条数据需要3页存储,而不是两页。数据库扩展页是8页,也就是如果一 张表存储空间不够了,我们要插入一条3k的数据,数据库不是分配一页,,而是8页,也就是64k空间,这个我们windows系统也是,我们见一个文本文 件,然后输入一个a,那么这时候系统为我们文件分配的内存不是2个字节,而是1k空间。
如果一个数据页大小只有8k,那么像txt,image这些数据怎么存储呢?
那么我们这时系统存储的是txt,image的堆地址,她们的数据存储在堆里,那么他们地址最多不会超过8字节。
3. 数据库内存,我们读取一条数据是先在内存里找,如果内存没有,我们就会在数据库里面找,然后把数据读到内存里面来。那么我们更新一条数据呢?
我们更新(增、删、改)一条数据不是commit的时候数据就写到数据库里了,而是数据库会有一个chekpoints,在 checkpoints的时候数据库,会一页一页的把数据往数据库里写。这个在sql2005里的时间大概是15分钟只需一次,那么没有交易的数据在哪里 呢?那么可能存在两个地方,一个是在temptdb里面,一个是在buffercahce里面。
4. 对大的系统数据库应注意几个问题,我们都知道数据库瓶颈是 磁盘阵列有I/O瓶颈,如果我们数据库超作频繁,这样我们数据库日志文件增大比较快,如果我们把数据库文件和日志文件放在一个磁盘里那么,会导致越来操作 数据库的数据越慢,那么我们可以把日志文件和数据文件放在 不同的磁盘里,一个磁盘两个通道,如果放在不同磁盘那么写数据和日志可以并行超作了,还有我们每天最好6个小时做一次日志备份,这样我们可以减小我们的日 志文件大小,因为日志文件备份后就从日志里面删除了。
5. 数据库文件组的利用,如果我们数据库设计很大,我们还可以设计数据库文件组,把不同的数据放在不同的文件组,不同文件组放在不同磁盘,如果表大,我们还可 以把一个表放在不同文件组,很多时候我们把一个表放在不同文件组,可能比放在一个文件组快,因为放在不同文件组是并行访问的,但是放在一个文件组需要顺序 访问,一般没有必要的情况下,还是建议大家做表分区。
6. 建数据库的时候我们需要注意,我们数据文件放在磁盘的格式fat32的允许数据库文件最大为2g如果我们建立好数据库后再发现这个问题就麻烦了,要不停的 加数据库文件,所以建议放在NTFs格式磁盘上,数据库最大容量修改规则,能改大不能该小,那么有没有把数据库改小的办法呢?有的压缩数据库。
这里我们可以压缩数据大小。
7. 备份数据库注意事项:
1.一定要选上下面那两个勾,这样保证我们备份成功。
我们备份数据库(特别是做维护计划的时候)的最好步骤一般用
1. 检查数据库的完整性
2. 日志尾备份(后面我们复灾的时候会讲到)
3. 备份
最好这几个是有顺序来自。
我们备份一周备份最好是周末完整备份,1-5差异备份,6小时做一次日志备份
8. 数据库性能监视打开方法:
比如我们监视应用程序引起的sqlserver死锁 添加监视:
我们可以看到如下:
都是0诶没有死锁,那么证明我们系统很健康啊。。。,但是监视一般是在服务器闲的时候监视,因为这个也是占用资源的。
有错误的地方欢迎大家拍砖,希望交流和共享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to implement student performance management function in Java? In the modern education system, student performance management is a very important task. By managing student performance, schools can better monitor students' learning progress, understand their weaknesses and strengths, and make more targeted teaching plans based on this information. In this article, we will discuss how to use Java programming language to implement student performance management functions. First, we need to determine the data structure of student grades. Typically, student grades can be represented as a

How to use Redis to implement distributed transaction management Introduction: With the rapid development of the Internet, the use of distributed systems is becoming more and more widespread. In distributed systems, transaction management is an important challenge. Traditional transaction management methods are difficult to implement in distributed systems and are inefficient. Using the characteristics of Redis, we can easily implement distributed transaction management and improve the performance and reliability of the system. 1. Introduction to Redis Redis is a memory-based data storage system with efficient read and write performance and rich data

WindowsServerBackup is a function that comes with the WindowsServer operating system, designed to help users protect important data and system configurations, and provide complete backup and recovery solutions for small, medium and enterprise-level enterprises. Only users running Server2022 and higher can use this feature. In this article, we will explain how to install, uninstall or reset WindowsServerBackup. How to Reset Windows Server Backup If you are experiencing problems with your server backup, the backup is taking too long, or you are unable to access stored files, then you may consider resetting your Windows Server backup settings. To reset Windows

Laravel extension package management: Easily integrate third-party code and functions Introduction: In Laravel development, we often use third-party code and functions to improve the efficiency and stability of the project. The Laravel extension package management system allows us to easily integrate these third-party codes and functions, making our development work more convenient and efficient. This article will introduce the basic concepts and usage of Laravel extension package management, and use some practical code examples to help readers better understand and apply it. What is Lara

How to set up and manage the network server on Kirin operating system? Kirin operating system is a Linux-based operating system independently developed in China. It has the characteristics of open source, security and stability, and has been widely used in China. This article will introduce how to set up and manage network servers on Kirin operating system, helping readers better build and manage their own network servers. 1. Install related software Before starting to set up and manage the network server, we need to install some necessary software. On Kirin OS, you can

When we use the win10 system, when we use the mouse to right-click the desktop or the right-click menu, we find that the menu cannot be opened and we cannot use the computer normally. At this time, we need to restore the system to solve the problem. Win10 right-click menu management cannot be opened: 1. First open our control panel, and then click. 2. Then click under Security and Maintenance. 3. Click on the right to restore the system. 4. If it still cannot be used, check whether there is something wrong with the mouse itself. 5. If you are sure there is no problem with the mouse, press + and enter. 6. After the execution is completed, restart the computer.

On the occasion of releasing the build 26040 version of Windows Server, Microsoft announced the official name of the product: Windows Server 2025. Also launched is the Windows11WindowsInsiderCanaryChannel version build26040. Some friends may still remember that many years ago someone successfully converted Windows NT from workstation mode to server mode, showing the commonalities between various versions of Microsoft operating systems. Although there are clear differences between Microsoft's current version of the server operating system and Windows 11, those who pay attention to the details may be curious: why Windows Server updated the brand,

How to manage and clean up hard disk space on Kirin operating system? Kirin operating system is a Linux-based operating system. Compared with other operating systems, Kirin provides more freedom and customizability. During long-term use, we often encounter the problem of insufficient hard disk space. At this time, we need to manage and clean up the hard disk space. This article will introduce how to manage and clean up hard disk space on Kirin operating system, including checking hard disk space usage, deleting unnecessary files, and using disk cleaning tools. first,
