dbcc命令能對資料庫進行維護,重點介紹內容:
一、checkalloc 磁碟空間一致性
二、checkcatalog 系統表一致性
三、checkconstraints約束完整性
四、checkdb 結構完整性
五、checktable 頁的完整性
六、dbreindex 索引
七、indexdefrag 整理索引碎片
八、shrinkdatabase 釋放空間
九、shrinkfile 釋放檔案空間
十、help 語句的語法資訊
一、dbcc checkalloc檢查指定資料庫的磁碟空間分配結構一致性《單使用者模式》。
語法dbcc checkalloc
(』database_name』[ , noindex《指定不檢查非系統表的非聚集索引》|
])[with《此四個引數不重要》 ]
例:use ufdata_999_2001
goalter database ufdata_999_2001 set single_user–sql7.0下同(sp_dboption 『ufdata_999_2001′,』single_user』, 『true』)
godbcc checkalloc(』ufdata_999_2001 『, repair_rebuild) with no_infomsgs
goalter database ufdata_999_2001 set multi_user–sql7.0(sp_dboption 『ufdata_999_2001′,』single_use*』, 『**lse』)
二、dbcc checkcatalog檢查指定資料庫中的系統表內及系統表間的一致性。
語法dbcc checkcatalog (』database_name 」 ) [ with no_infomsgs ]
例:dbcc checkcatalog (』ufdata_999_2001 『) with no_infomsgs
三、dbcc checkconstraints檢查指定表上的指定約束或所有約束的完整性。
語法dbcc checkconstraints
[( 'table_name' | 'constraint_name' )][ with ]
例:dbcc checkconstraints with all_constraints
四、 dbcc checkdb檢查指定資料庫中的所有物件的分配和結構完整性《單使用者模》。
語法dbcc checkdb
( 『database_name』 [ , noindex | repair_allow_data_loss | repai*_**st |
repair_rebuild } ] ) [ with ]
例:use ufdata_999_2001
goalter database ufdata_999_2001 set single_user
dbcc checkdb (ufdata_999_2001, repair_rebuild) with no_infomsgs
goalter database ufdata_999_2001 set multi_user
go五、dbcc checktable檢查指定表或檢視的資料、索引及 text、ntext 和 image 頁的完整性《單使用者模式》。
語法dbcc checktable
( 『table_name』 | 『view_name』 [ , noindex | index_id| ] ) [with ]
例:use ufdata_999_2001
goalter database ufdata_999_2001 set single_user
godbcc checktable (』code』, repair_rebuild) with no_infomsgs
goalter database ufdata_999_2001 set multi_user
六、dbcc dbreindex重建指定資料庫中表的乙個或多個索引。
語法dbcc dbreindex
( [ 'database.owner.table_name' [ , index_name [ , fillfactor ]] ])
[ with no_infomsgs ]
例:dbcc dbreindex (code) with no_infomsgs
七、dbcc indexdefrag整理指定的表或檢視的聚集索引和輔助索引碎片。
語法dbcc indexdefrag ( , , ) [ with no_infomsgs ]
例:dbcc indexdefrag (ufdata_999_2001,code,ccode_name) with no_infomsgs
八、dbcc shrinkdatabase釋放指定資料庫中的資料檔案空間。
語法(sql7.0用shrinkdb)
dbcc shrinkdatabase
( database_name [ , target_percent《釋放後資料庫檔案中所要的剩餘可用空間百分比》]
[ , ] } )
例:use ufdata_999_2001
sp_helpfile -檢視資料庫有關資訊後修改下面的語句後執行即可
godbcc shrinkfile (ufmodel, 70)
dbcc shrinkfile (ufmodel_log, 7)
go十、dbcc help返回指定的 dbcc 語句的語法資訊。
語法dbcc help ( 『dbcc_statement』 | @dbcc_statement_var | 『?』 )
例:dbcc help(』?')
cacti資料庫修復命令
報錯 2019年08月23日 18 30 22 pm cmdphp poller 0 error a db exec failed error 145 sql insert intocacti.syslog facilities facility select distinct facility f...
SQLite資料庫損壞修復
the database disk image is malformed 進入到sqlite3操作指定的資料庫 或者直接 sqlite3 e item.db 操作此資料庫 sqlite databases main e item.db sqlite tables 顯示列表 檢查資料庫是否損壞 sql...
資料庫表損壞的修復
用命令列訪問出現 開始時使用myisamchk r o home test test user.myi進行修復,出現錯誤 myisamchk error myisam sort buffer size is too small。df發現是mysql temp目錄太小,此錶太大。更改my.cnf檔案修...