sqlserver数据库被质疑(suspect)的解决方案

合集下载

sqlserver数据库被质疑(suspect)的解决方案

sqlserver数据库被质疑(suspect)的解决方案
1、在SQL查询分析器中执行以下命令,以允许更sp_configure 'allow updates',1
reconfigure with override
go
2将这个数据库置为紧急模式:
update sysdatabases set status = 32768 where name = 'db_name'
GO
如果在执行DBCC CHECKDB(‘db_name', REPAIR_ALLOW_DATA_LOSS)命令时提示说数据库未处于单用户模式状态的话,则重新启动SQL Server服务,然后继续尝试。
5、若成功修复了数据库中的错误:
重新执行DBCC CHECKDB(‘db_name')命令,确认数据库中已没有错误存在。
清除数据库的置疑状态:sp_resetstatus 'db_name'
清除数据库的单用户模式状态:sp_dboption 'db_name','single user','false'
重新启动SQL Server服务,如果一切正常的话,则数据库已经成功恢复。
6、修改数据库的标志
update sysdatabases set status=12 where name =''db_name'( 'db_name'表示相应的数据库名字)
文档编号:
WD200712140001参考方案
文档标题:
sqlserver数据库被质疑(suspect)的解决方案
操作系统:
WIN 2000 PRO
数据库:
Sql Server 2000

SQL数据库置疑的解决方法

SQL数据库置疑的解决方法

SQL2000数据库置疑的解决方法首先,在任何操作之前,必须要备份数据库(重要)一、分离数据库1、点击“程序》Microsoft SQL Server》企业管理》”,打开企业管理器2、展开服务器组,然后展开服务器,选中要分离的数据库3、点击鼠标右键“所有任务》分离数据库”,出现如下窗口4、点击确定,该选定的数据库就被分离。

5.分离后,把原数据库里面.MDF(主数据文件).LDF(事务日志文件)这两个文件复制到目标盘下,例:D盘下注意事项,只有“使用本数据库的连接”数为0时,该数据库才能分离。

所以分离数据库时尽量断开所有对要分离数据库操作的连接,如果还有连接数据库的程序,会出现数据库的连接状态窗口,显示正在连接此数据库的机器以及名称,点击清除按钮将从服务器强制断开现有的连接。

二、附加数据库1、在附加数据库之前,首先要移动数据库文件在附加数据库之前,您必须将与数据库关联的 .MDF(主数据文件).LDF(事务日志文件)这两个文件复制到目标硬盘下,或是同一服务器的不同硬盘目录下。

这两个文件一般位于C:\Program Files\Microsoft SQL Server\MSSQL\Data目录下。

2、点击“程序》Microsoft SQL Server》企业管理》”,打开企业管理器3、展开服务器组,然后展开服务器4、右击"数据库",然后选择“所有任务》附加数据库”,弹出窗口5、输入要附加的数据库的MDF名称。

如果不确定文件位于何处,单击浏览("...")搜索。

若要确保指定的 MDF 文件正确,请单击"验证"。

在"附加为"框内,输入数据库的名称。

数据库名称不能与任何现有数据库名称相同。

指定数据库的所有者6、单击"确定"按钮。

新附加的数据库的数据库节点即创建在"数据库"文件夹中重启双机1.此时数据库分离,附加完成,必须重启一次双机修复置疑1,双机重启后,数据库置疑下面所有修复置疑的语法,在没有特别提到时,默认数据库都请选择(Master)数据库)2,修复置疑(必须在SQL的查询分析器中才能进行数据修复置疑工作)A、打开查询分析器,当数据置疑之后在查询分析器中是看不到置疑的数据库名称的,所以进入查询分析器之后,所选数据库默认(Master)数据库即可。

sql server数据库被置疑解决方法(The SQL Server database is the solution to doubt)

sql server数据库被置疑解决方法(The SQL Server database is the solution to doubt)

sql server数据库被置疑解决方法(The SQL Server database is thesolution to doubt)First, make sure that you have backed up the.Mdf and.Ldf files.2. create a database with the same name in SQL Server, and then stop the SQL Server service.3. overwrite the.Mdf and.Ldf files of the new database with the original.Mdf and.Ldf files.4. restart the SQL Server service, which should see the database in doubt (Suspect) state.5. in the SQL query analyzer, execute the following command to allow updating of the system tables:Use masterGoSp_configure 'allow updates', 1Reconfigure with overrideGo6. place this database as an emergency mode:Update, sysdatabases, set, status = 32768, where, name='db_name'Go7. check the errors in the database using the DBCC CHECKDB command:DBCC CHECKDB ('db_name')GO8. if the DBCC CHECKDB command fails, go to the tenth step, or you will first set the database in a single user mode, and then try to fix it:Sp_dboption'db_name',' single user ',' true 'DBCC CHECKDB ('db_name', REPAIR_ALLOW_DATA_LOSS)GOIf the DBCC CHECKDB ("db_name", "REPAIR_ALLOW_DATA_LOSS") command is prompted to indicate that the database is not in a single user mode, restart the SQL Server service, and then proceed with the attempt.9. if the DBCC CHECKDB ('db_name', REPAIR_ALLOW_DATA_LOSS) command fails, go to the tenth step, otherwise the database error will be repaired successfully:Rerun the DBCC CHECKDB ('db_name') command to make sure there are no errors in the database.Clear the query status of the database:sp_resetstatus'db_name'Clear the single user mode state of the database:sp_dboption'db_name',' single user ',' false 'Restart the SQL Server service and, if everything is OK, the database has been successfully restored.10. if the above steps do not solve the problem, please refer to the document in the attached file and try to restore the data in the database by rebuilding the transaction log.If you have only MDF files, the problem is more complex, and we need to rebuild the transaction log directly:1. create a database with the same name in SQL Server, and then stop the SQL Server service.2. overwrite the new.Mdf file with the original LDF file and delete the log file (.Ldf).3. start the SQL Server service and set the database as an emergency mode (ibid.: steps 5 and 6).4. stop and restart the SQL Server service.5. perform the following commands to rebuild the database log file: (here is an example that you will need to use your actual database name)DBCC REBUILD_LOG ('cas_db','D:\cas_db\cas_db_Log.LDF')6. reset the database to a single user mode.The Sql Server database is the solution to doubtEnvironment WIN2000, SQL, server2kProblem: when a database is generally updated, queries are suddenly "doubted" and cannot be used any moreYou can't solve the problem by dealing with it yourself:1, close the SQL Server database, the corresponding database.Mdf.Ldf file moved to other directories, delete the original database2. Start the SQL Server database and create a new database with the same name,3, close the SQL Server database, with the original database.Mdf.Ldf file overwrite new database corresponding file. The problem still exists, it doesn't work.Search for information and solve problems through results online:1, close the SQL Server database, will be questioned database file (.Mdf.Ldf) copy back up.2. Open the SQL Server database and create a new database with the same name,3, close the SQL Server database and overwrite the new database's same name file with the backup.Mdf file4. Open the SQL Server database and execute the following statement in the query analyzer, allowing direct modification of the system directoryUse masterGoSp_configure,'allow, updates', 1GoReconfigure with overrideGoUpdate, sysdatabases, set, status=-32768, where, dbid=DB_ID ('newdb')5. Rebuild the new database logDBCC rebuild_log ('newdb','C:\Program, Files\Microsoft, SQL, Server\MSSQL\Data\newdb_log.ldf')With this step in progress, you may find that the data is ina read-only / offline / state, and proceed to the following operation6, DBCC checkDBCC CHECKDB ('newdb')When you go to this section, you may find that there are errors. You can look at some of the data tables of the prompt. If it is not a critical table, you can let go first.7, set the database as a normal stateSp_dboption,'newdb','dbo, use, Only','false'8, close the database directly modify permissions, do not allow direct modification of the system directorySp_configure,'allow, updates', 0GoReconfigure with overrideGoOf course, my data did not recover at the first step. I've done it all over again, and my database has been restored to normal, and I feel very happy.Total feel, personal feeling, the database was questioned,should be because the database log is too large, the database log has reached 15G. But I'm not sure yet. Keep studying.Come on.SQL2000 database query solution 2009-03-21 09:12 follows the following steps:1. create a new database with the same name2. stop SQL server again3. overwrite the new database file with the same name by using the backup database MDF file4. restart SQL Server5., when you open the enterprise manager, the new database of the same name will appear doubt, first ignore, execute the following statement (pay attention to modify the database name)USE MASTERGOSP_CONFIGURE,'ALLOW, UPDATES', 1, RECONFIGURE, WITH, OVERRIDEGO"UPDATE SYSDATABASES SET STATUS =32768 WHERE NAME='database name'GoSp_dboption 'database name', ''single user' ',''true''GoDBCC CHECKDB ('database name')Go"Update sysdatabases set status =28 where name='database name'GoSp_configure,'allow, updates', 0, reconfigure, with, overrideGoSp_dboption 'database name', ''single user' ',''false''GoDatabase query recovery classic/********************************************************** ******** this kind of fault is usually caused by disk read and write problems.* the following statement is the SQL that fixes the database of the headquarters. If you need to fix the database of the segment, change'hbposv5'to'hbposv5_branch'* supermarket star system is implemented directly* shortcut, Invoicing series, pleasechange'hbposv5'to'isd2001v3', and if it is subsection, change to'isd2001v3_branch'* business series, please change'hbposv5'to'isd2001v4', if the segment, changed to'isd2001v4_branch'*********************************************************** *******/Please perform the following statements in the query analyzer. Disconnect all other database connections before execution. It's better to disconnect the network cableUSE masterGoSingle user modeEXEC, sp_dboption,'hbposv5','single, user','TRUE'Go-- database checkingDBCC CHECKDB ('hbposv5')Go- if you return the result with a red prompt text that indicates an error in the database, you need to fix it-- database repairDBCC CHECKDB ('hbposv5', repair_rebuild)GoAgain, database check, and if there is no red prompt text in the return result, the repair is successful;DBCC CHECKDB ('hbposv5')GoOtherwise it means higher levels of repair are required. Try changing the'repair_rebuild'of the repair statementto'repair_allow_data_loss', and then check the database again.- if there are any errors that have not been repaired,Before you quit, be sure to execute the following statement and return to the multi-user modeEXEC, sp_dboption,'hbposv5','single, user','FALSE'GoDatabase query processingStep 1:Create a new database named as the name of the original database.Step 2:Stop SQL ServerStep 3:Replace the old database's MDF file with the corresponding MDF file of the new database and delete the LDF file.Step 4:Restart the SQL Server service, and then run the following command:Use MasterGoSp_configure,'allow, updates', 1Reconfigure with overrideGoBegin tranUpdate, sysdatabases, set, status = 32768, where, name='hbposv5'--Verify, one, row, is, updated, before, committingCommit tranStep 5:Stop SQL and restart the SQL Server service,Then run the following command:DBCC TRACEON (3604)DBCC REBUILD_LOG('db_name','c:\mssql7\data\hbposv5_log.ldf')GoStep 6:Stop SQL, then restart the SQL Server service, and then run: Use masterUpdate, sysdatabases, set, status = 8, where, name ='hbposv5'GoSp_configure,'allow, updates', 0Reconfigure with overrideGoStep 7:Run DBCC CHECKDB (hbposv5) to check the integrity of the databaseNote: all must be replaced with the actual database name.。

解决SQLServer 2008 数据库质疑

解决SQLServer 2008 数据库质疑

解决SQLServer2008数据库质疑(挂起)问题Step1.执行语句,改变数据库状态EXEC SP_RESETSTATUS'Your DBName'GOStep2:重置数据库状态之后,我们就应该对质疑的数据库执行DBCC CHECKDB命令,查看下为什么数据库会出现质疑状态.DBCC CHECKDB('Your DBName')WITH NO_INFOMSGS,ALL_ERRORMSGSGoStep3:找到原因之后,那么就好解决了.看报错信息中,已说明了PK中存在重复值.首先,将每个索引的脚本导出为sql文件.之后再将表中主键栏位里的duplicate的行删除掉Step4:现在最好再立即执行下DBCC CHECKDB命令确认下是否还有错误信息.之后确认没有,那么再将之前索引的脚本创建进去.Step5:在Index创建完毕之后,立即执行下DBCC CHECKDB命令确认下是否还有错误信息.确认无误,那么就需要立即对数据库执行一次完全备份作业.针对SQL2000挂起情况进行修复Step1:设置数据库为紧急模式Use Mastersp_configure'allow updates',1reconfigure with overrideGOUPDATE sysdatabases SET status=32768where name='TEST'GOStep2:停止数据库服务通过Windows服务或者SQLServer管理器.Step3:把原始数据库的数据文件DBNAME_DAT.MDF,DBNAME_LOG.LDF移走Step4:启动SQL Server服务Step5.重新建立一个同名的数据库TEST;USE masterGOCREATE DATABASE TESTON(NAME=DBNAME_DAT,FILENAME='C:',SIZE=10,FILEGROWTH=5)LOG ON(NAME='DBNAME_LOG',FILENAME='g:',SIZE=5MB,FILEGROWTH=5MB)GOStep6:设置数据库运行在单用户的模式:USE MASTERGOALTER DATABASE TEST SET SINGLE_USERGOStep7:停掉SQL服务Step8:把原来的数据文件再覆盖回来Step9:启动SQL Server服务Step10:设置数据库为紧急模式Use Mastersp_configure'allow updates',1reconfigure with overrideGOUPDATE sysdatabases SET status=32768where name='TEST'GOStep11:修复数据库错误DBCC CHECKDB('TEST',REPAIR_ALLOW_DATA_LOSS)Step12.恢复数据库为多用户模式USE MASTERGOALTER DATABASE TEST SET MULTI_USERGOStep13.恢复SQLSERVER原始的配置USE MATERGOUPDATE sysdatabases SET status=4194320where name='TEST'GOStep14:配置SQLSERVER不允许更新系统表USE MASTERGOsp_configure'allow updates',0reconfigure with overrideGOStep15:重新启动MSSQLSERVER服务,最好重新启动操作系统.Step16:备份数据库特殊情况:不知道为什么,质疑修复后,数据库恢复正常了。

SQL数据库置疑解决方案(原因、预防、修复)附图

SQL数据库置疑解决方案(原因、预防、修复)附图

SQL数据库置疑解决方案一、数据库置疑产生的原因1、SQL Server所在分区空间是否够?数据库文件大小是否达到最大文件限制?FAT32的格式只支持4G以内的文件。

2、数据库文件损坏或被非正常删除时出现这种情况。

3、病毒防火墙的扫描也会引起数据库置疑。

4、当SQL Server启动时,将会尝试获得对数据库文件的排他访问权,如果此时该文件被其他程序占用,或者遗失,数据库将会被标记为置疑。

5、电脑非法关机也会造成数据库置疑。

6、电脑磁盘有坏道有可能造成数据库置疑。

二、数据库置疑的预防1、数据库存放的盘符,空间是否够大,经常检查盘符的空间。

2、数据库存放的盘符的格式设置为NTFS格式。

3、进行病毒清除时,尽量把SQL服务停掉,再进行检查。

4、尽量减少非正常关机。

5、建议客户购买后备电源。

页脚内容16、给客户实施软件之后一定要做好自动备份。

7、建议客户每隔一定时间手动备份一次。

三、数据库置疑的修复1、正常的备份、SQL数据库恢复方式正常方式下,我们要备份一个数据库,首先要先将该数据库从运行的数据服务器中断开,或者停掉整个数据库服务器,然后复制文件。

卸下数据库的命令:Sp_detach_db 数据库名连接数据库的命令:Sp_attach_db或者sp_attach_single_file_dbs_attach_db [@dbname =] ′dbname′, [@filename1 =] ′filename_n′[,...16]sp_attach_single_file_db [@dbname =] ′dbname′, [@physname =] ′physical_name′使用此方法可以正确恢复SQL Sever7.0和SQL Server 2000的数据库文件,要点是备份的时候一定要将mdf和ldf两个文件都备份下来,mdf文件是数据库数据文件,ldf是数据库日志文件。

例子:假设数据库为pdm,其数据文件为pdm_data.mdf,日志文件为pdm_log.ldf。

SqlServer数据库(可疑)解决办法4种

SqlServer数据库(可疑)解决办法4种

SqlServer数据库(可疑)解决办法4种重启服务--------------------------------------------------日志文件丢了,建一个日志文件--------------------------------------------------SQL SERVER 2005 数据库状态为“可疑”的解决方法--MyDB为修复的数据名USE MASTERGOSP_CONFIGURE 'ALLOW UPDATES',1 RECONFIGURE WITH OVERRIDEGOALTER DATABASE MyDB SET EMERGENCYGOsp_dboption 'MyDB', 'single user', 'true'GODBCC CHECKDB('MyDB','REPAIR_ALLOW_DATA_LOSS')GOALTER DATABASE MyDB SET ONLINEGOsp_configure 'allow updates', 0 reconfigure with overrideGOsp_dboption 'MyDB', 'single user', 'false'GO-------------------------------------------------当数据库发生这种操作故障时,可以按如下操作步骤可解决此方法,打开数据库里的Sql 查询编辑器窗口,运行以下的命令。

1、修改数据库为紧急模式ALTER DATABASE Zhangxing SET EMERGENCY2、使数据库变为单用户模式ALTER DATABASE Zhangxing SET SINGLE_USER3、修复数据库日志重新生成,此命令检查的分配,结构,逻辑完整性和所有数据库中的对象错误。

SQL数据库置疑解决方法

SQL数据库置疑解决方法

SQL数据库置疑解决方法
一、SQL数据库置疑
1.数据库安全问题
为了保护数据库,需要确保数据库中的信息不被恶意攻击、篡改或盗窃,从而避免造成不可挽回的损失。

2.数据库可靠性问题
可靠性是指数据库系统必须在不同的时间片段可靠运行,即使是在发生系统故障的情况下,用户也能够一直获取服务。

只有数据库系统可靠性良好,才能够实现数据库系统的高安全性要求。

3.数据库性能问题
要满足用户的需求,必须保证数据库服务器能够达到最佳性能,避免出现数据库访问运行缓慢的问题,以及查询数据库时出现的查询延时、查询次数多等问题。

4.数据库维护问题
数据库系统是一个复杂的系统,在日常运行中难免会出现数据库系统故障、业务变更需求等情况。

数据库系统维护对于保证系统可靠性,提高系统性能至关重要。

1.数据库安全问题
(1)做好安全设置,为数据库设置正确的授权,只允许拥有访问权限的用户进行访问,并设置访问日志,记录访问和更改的用户,以及操作的时间等信息。

(2)定期备份数据库,将备份数据存放到安全的位置。

SqlServer数据库被置疑解决方法

SqlServer数据库被置疑解决方法

Sql Server数据库被置疑解决方法首先确认已经备份了.mdf和.ldf文件。

2.在SQL Server中新建一个同名的数据库,然后停止SQL Server服务。

3.用原有的.mdf和.ldf文件覆盖新建数据库对应的.mdf和.ldf文件。

4.重新启动SQL Server服务,这是应该会看到这个数据库处于置疑(Suspect)状态。

5.在SQL查询分析器中执行以下命令,以允许更新系统表:use mastergosp_configure‘allow updates’,1reconfigure with overridego6.将这个数据库置为紧急模式:update sysdatabases set status=32768where name= 'db_name'go7.使用DBCC CHECKDB命令检查数据库中的错误:DBCC CHECKDB(‘db_name’)GO8.如果DBCC CHECKDB命令失败,请转至第10步,否则先将数据库置为单用户模式,再尝试对其进行修复:sp_dboption'db_name',’single user’,’true’DBCC CHECKDB(‘db_name’,REPAIR_ALLOW_DATA_LOSS)GO如果在执行DBCC CHECKDB(‘db_name’, REPAIR_ALLOW_DATA_LOSS)命令时提示说数据库未处于单用户模式状态的话,则重新启动SQL Server服务,然后继续尝试。

9.如果DBCC CHECKDB(‘db_name’,REPAIR_ALLOW_DATA_LOSS)命令失败,请转至第10步,否则若成功修复了数据库中的错误:重新执行DBCC CHECKDB(‘db_name’)命令,确认数据库中已没有错误存在。

清除数据库的置疑状态:sp_resetstatus'db_name'清除数据库的单用户模式状态:sp_dboption'db_name',’single user’,’false’重新启动SQL Server服务,如果一切正常的话,则数据库已经成功恢复。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
清除数据库的置疑状态:sp_resetstatus 'db_name'
清除数据库的单用户模式状态:sp_dboption 'db_name','single user','false'
重新启动SQL Server服务,如果一切正常的话,则数据库已经成功恢复。
6、修改数据库的标志
update sysdatabases set status=12 where name =''db_name'( 'db_name'表示相应的数据库名字)
GO
如果在执行DBCC CHECKDB(‘db_name', REPAIR_ALLOW_DATA_LOSS)命令时提示说数据库未处于单用户模式状态的话,则重新启动SQL Server服务,然后继续尝试。
5、若成功复了数据库中的错误:
重新执行DBCC CHECKDB(‘db_name')命令,确认数据库中已没有错误存在。
1、在SQL查询分析器中执行以下命令,以允许更新系统表:
use master
go
sp_configure 'allow updates',1
reconfigure with override
go
2将这个数据库置为紧急模式:
update sysdatabases set status = 32768 where name = 'db_name'
文档编号:
WD200712140001参考方案
文档标题:
sqlserver数据库被质疑(suspect)的解决方案
操作系统:
WIN 2000 PRO
数据库:
Sql Server 2000
软件版本:
未知
软件模块:
其他
问题描述:
sqlserver数据库被质疑
产生原因:
数据库质疑
解决方法:
:请根据实际情况修改db_name
go
3.使用DBCC CHECKDB命令检查数据库中的错误:
DBCC CHECKDB(‘db_name')
GO
4.先将数据库置为单用户模式,再尝试对其进行修复:
sp_dboption 'db_name','single user','true'
DBCC CHECKDB(‘db_name', REPAIR_ALLOW_DATA_LOSS)
相关文档
最新文档