在论坛看到收缩主数据库在 Mirror 上没有效果的问题。以前我也认为在主数据库上执行的 DBCC Shirnkfile 命令会在 Mirror 数据库上重做,所以收缩主数据库可以导致Mirror数据库跟着收缩。事实不是。从MS网站找到的资料: When you use databasemirroring in M
在论坛看到收缩主数据库在Mirror上没有效果的问题。以前我也认为在主数据库上执行的DBCC Shirnkfile命令会在Mirror数据库上重做,所以收缩主数据库可以导致Mirror数据库跟着收缩。事实不是。从MS网站找到的资料:
When you use databasemirroring in Microsoft SQL Server 2005, SQL Server automatically propagates anychanges on the principal database to the mirror database. However, if you runthe DBCC SHRINKDATABASE statement or the DBCC SHRINKFILE statements to shrinkthe principal database,theshrink operation is not duplicated on the mirror database.
CAUSE:Database mirroring will change the physical file sizes only after a checkpoint.
在主数据库上执行DBCC SHRINKDATABASE或者DBCC SHRINKFILE的命令,收缩的操作不会在Mirror数据库上重做。原因是:Mirror数据库只在checkpoint动作后才会修改物理文件的大小。
有几个办法可以解决这个问题:
1. 在Master数据库执行下面的命令创建存储过程,在主数据库上运行创建的存储过程。
use master
go
if object_id('sp_shrink_mirrored_database','P') is not null
drop proc sp_shrink_mirrored_database
go
create procedure sp_shrink_mirrored_database@dbnamesysname, @target_percent int = null
as
begin
declare@filenamesysname
declare@filesizeint
declare@sqlnvarchar(4000)
if @target_percent is null
dbccshrinkdatabase(@dbname)
else
dbccshrinkdatabase(@dbname,@target_percent)
declareccursor for
select[name],[size] from sys.master_fileswhere type=0and database_id = db_id(@dbname)
open c
fetch next from cinto @filename,@filesize
while @@fetch_status=0
begin
set @filesize=(@filesize+1)*8
set @sql='alter database ['+ @dbname + '] modify file ( name='
+ @filename + ', size='+ cast(@filesizeas nvarchar)+ 'kb )'
executesp_executesql@sql
fetchnextfrom c into @filename,@filesize
end
close c
deallocatec
end
go
2. 在主数据库上执行收缩命令之后手动允许checkpoint命令。
3. 可以考虑做Failover将辅助的直接变成主的,执行收缩命令。
另外建议经常对数据库进行日志备份,如果发现日志文件增长的快可以考虑增加备份的频率,这样可以导致日志空间重用,从而减少日志文件的增长。
另外在2008版本上测试不会有这个问题,收缩的命令可以成功在Mirror上面起作用,所以这个现象可能只限于2005的版本。

mysql'sblobissuitableForStoringBinaryDataWithInareLationalDatabase,而ilenosqloptionslikemongodb,redis和calablesolutionsolutionsolutionsoluntionsoluntionsolundortionsolunsonstructureddata.blobobobissimplobisslowdeperformberbutslowderformandperformancewithlararengedata;

toaddauserinmysql,使用:createUser'username'@'host'Indessify'password'; there'showtodoitsecurely:1)choosethehostcarecarefullytocon trolaccess.2)setResourcelimitswithoptionslikemax_queries_per_hour.3)usestrong,iniquepasswords.4)Enforcessl/tlsconnectionswith

toAvoidCommonMistakeswithStringDatatatPesInMysQl,CloseStringTypenuances,chosethirtightType,andManageEngencodingAndCollationsEttingSefectery.1)usecharforfixed lengengtrings,varchar forvariable-varchar forbariaible length,andtext/blobforlargerdataa.2 seterters seterters seterters

mysqloffersechar,varchar,text,and denumforstringdata.usecharforfixed Lengttrings,varcharerforvariable長度,文本forlarger文本,andenumforenforcingDataAntegrityWithaEtofValues。

優化MySQLBLOB請求可以通過以下策略:1.減少BLOB查詢頻率,使用獨立請求或延遲加載;2.選擇合適的BLOB類型(如TINYBLOB);3.將BLOB數據分離到單獨表中;4.在應用層壓縮BLOB數據;5.對BLOB元數據建立索引。這些方法結合實際應用中的監控、緩存和數據分片,可以有效提升性能。

掌握添加MySQL用戶的方法對於數據庫管理員和開發者至關重要,因為它確保數據庫的安全性和訪問控制。 1)使用CREATEUSER命令創建新用戶,2)通過GRANT命令分配權限,3)使用FLUSHPRIVILEGES確保權限生效,4)定期審計和清理用戶賬戶以維護性能和安全。

chosecharforfixed-lengthdata,varcharforvariable-lengthdata,andtextforlargetextfield.1)chariseffity forconsistent-lengthdatalikecodes.2)varcharsuitsvariable-lengthdatalikenames,ballancingflexibilitibility andperformance.3)

在MySQL中處理字符串數據類型和索引的最佳實踐包括:1)選擇合適的字符串類型,如CHAR用於固定長度,VARCHAR用於可變長度,TEXT用於大文本;2)謹慎索引,避免過度索引,針對常用查詢創建索引;3)使用前綴索引和全文索引優化長字符串搜索;4)定期監控和優化索引,保持索引小巧高效。通過這些方法,可以在讀取和寫入性能之間取得平衡,提升數據庫效率。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SublimeText3漢化版
中文版,非常好用

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

Dreamweaver CS6
視覺化網頁開發工具

Atom編輯器mac版下載
最受歡迎的的開源編輯器