search
HomeDatabaseMysql TutorialSQL 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空间。

SQL Server管理 这些你懂吗?

  如果一个数据页大小只有8k,那么像txt,image这些数据怎么存储呢?

  那么我们这时系统存储的是txt,image的堆地址,她们的数据存储在堆里,那么他们地址最多不会超过8字节。

  3. 数据库内存,我们读取一条数据是先在内存里找,如果内存没有,我们就会在数据库里面找,然后把数据读到内存里面来。那么我们更新一条数据呢?

  我们更新(增、删、改)一条数据不是commit的时候数据就写到数据库里了,而是数据库会有一个chekpoints,在 checkpoints的时候数据库,会一页一页的把数据往数据库里写。这个在sql2005里的时间大概是15分钟只需一次,那么没有交易的数据在哪里 呢?那么可能存在两个地方,一个是在temptdb里面,一个是在buffercahce里面。

  4. 对大的系统数据库应注意几个问题,我们都知道数据库瓶颈是 磁盘阵列有I/O瓶颈,如果我们数据库超作频繁,这样我们数据库日志文件增大比较快,如果我们把数据库文件和日志文件放在一个磁盘里那么,会导致越来操作 数据库的数据越慢,那么我们可以把日志文件和数据文件放在 不同的磁盘里,一个磁盘两个通道,如果放在不同磁盘那么写数据和日志可以并行超作了,还有我们每天最好6个小时做一次日志备份,这样我们可以减小我们的日 志文件大小,因为日志文件备份后就从日志里面删除了。

  5. 数据库文件组的利用,如果我们数据库设计很大,我们还可以设计数据库文件组,把不同的数据放在不同的文件组,不同文件组放在不同磁盘,如果表大,我们还可 以把一个表放在不同文件组,很多时候我们把一个表放在不同文件组,可能比放在一个文件组快,因为放在不同文件组是并行访问的,但是放在一个文件组需要顺序 访问,一般没有必要的情况下,还是建议大家做表分区。

  6. 建数据库的时候我们需要注意,我们数据文件放在磁盘的格式fat32的允许数据库文件最大为2g如果我们建立好数据库后再发现这个问题就麻烦了,要不停的 加数据库文件,所以建议放在NTFs格式磁盘上,数据库最大容量修改规则,能改大不能该小,那么有没有把数据库改小的办法呢?有的压缩数据库。

SQL Server管理 这些你懂吗?

  这里我们可以压缩数据大小。

  7. 备份数据库注意事项:

  1.一定要选上下面那两个勾,这样保证我们备份成功。

SQL Server管理 这些你懂吗?

  我们备份数据库(特别是做维护计划的时候)的最好步骤一般用

  1. 检查数据库的完整性

  2. 日志尾备份(后面我们复灾的时候会讲到)

  3. 备份

  最好这几个是有顺序来自。

  我们备份一周备份最好是周末完整备份,1-5差异备份,6小时做一次日志备份

  8. 数据库性能监视打开方法:

SQL Server管理 这些你懂吗?

  比如我们监视应用程序引起的sqlserver死锁 添加监视:

SQL Server管理 这些你懂吗?

  我们可以看到如下:

SQL Server管理 这些你懂吗?

  都是0诶没有死锁,那么证明我们系统很健康啊。。。,但是监视一般是在服务器闲的时候监视,因为这个也是占用资源的。

  有错误的地方欢迎大家拍砖,希望交流和共享。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to Grant Permissions to New MySQL UsersHow to Grant Permissions to New MySQL UsersMay 09, 2025 am 12:16 AM

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

How to Add Users in MySQL: A Step-by-Step GuideHow to Add Users in MySQL: A Step-by-Step GuideMay 09, 2025 am 12:14 AM

ToaddusersinMySQLeffectivelyandsecurely,followthesesteps:1)UsetheCREATEUSERstatementtoaddanewuser,specifyingthehostandastrongpassword.2)GrantnecessaryprivilegesusingtheGRANTstatement,adheringtotheprincipleofleastprivilege.3)Implementsecuritymeasuresl

MySQL: Adding a new user with complex permissionsMySQL: Adding a new user with complex permissionsMay 09, 2025 am 12:09 AM

ToaddanewuserwithcomplexpermissionsinMySQL,followthesesteps:1)CreatetheuserwithCREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';.2)Grantreadaccesstoalltablesin'mydatabase'withGRANTSELECTONmydatabase.TO'newuser'@'localhost';.3)Grantwriteaccessto'

MySQL: String Data Types and CollationsMySQL: String Data Types and CollationsMay 09, 2025 am 12:08 AM

The string data types in MySQL include CHAR, VARCHAR, BINARY, VARBINARY, BLOB, and TEXT. The collations determine the comparison and sorting of strings. 1.CHAR is suitable for fixed-length strings, VARCHAR is suitable for variable-length strings. 2.BINARY and VARBINARY are used for binary data, and BLOB and TEXT are used for large object data. 3. Sorting rules such as utf8mb4_unicode_ci ignores upper and lower case and is suitable for user names; utf8mb4_bin is case sensitive and is suitable for fields that require precise comparison.

MySQL: What length should I use for VARCHARs?MySQL: What length should I use for VARCHARs?May 09, 2025 am 12:06 AM

The best MySQLVARCHAR column length selection should be based on data analysis, consider future growth, evaluate performance impacts, and character set requirements. 1) Analyze the data to determine typical lengths; 2) Reserve future expansion space; 3) Pay attention to the impact of large lengths on performance; 4) Consider the impact of character sets on storage. Through these steps, the efficiency and scalability of the database can be optimized.

MySQL BLOB : are there any limits?MySQL BLOB : are there any limits?May 08, 2025 am 12:22 AM

MySQLBLOBshavelimits:TINYBLOB(255bytes),BLOB(65,535bytes),MEDIUMBLOB(16,777,215bytes),andLONGBLOB(4,294,967,295bytes).TouseBLOBseffectively:1)ConsiderperformanceimpactsandstorelargeBLOBsexternally;2)Managebackupsandreplicationcarefully;3)Usepathsinst

MySQL : What are the best tools to automate users creation?MySQL : What are the best tools to automate users creation?May 08, 2025 am 12:22 AM

The best tools and technologies for automating the creation of users in MySQL include: 1. MySQLWorkbench, suitable for small to medium-sized environments, easy to use but high resource consumption; 2. Ansible, suitable for multi-server environments, simple but steep learning curve; 3. Custom Python scripts, flexible but need to ensure script security; 4. Puppet and Chef, suitable for large-scale environments, complex but scalable. Scale, learning curve and integration needs should be considered when choosing.

MySQL: Can I search inside a blob?MySQL: Can I search inside a blob?May 08, 2025 am 12:20 AM

Yes,youcansearchinsideaBLOBinMySQLusingspecifictechniques.1)ConverttheBLOBtoaUTF-8stringwithCONVERTfunctionandsearchusingLIKE.2)ForcompressedBLOBs,useUNCOMPRESSbeforeconversion.3)Considerperformanceimpactsanddataencoding.4)Forcomplexdata,externalproc

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.