我们公司是做应用软件的,昨天有个客户的数据库质疑了,附加数据库也失败了,按照总部的文档资料重建了日志,数据可以查询了,但是还是不能新增.在网上找了些资料,问题已经解决了,但是想弄明白,我对sql懂的很少. 先谢谢各位
use master
               update   sysdatabases   set status = 8   where   name = 'db_name'  
                请问 1.把status改成8有什么作用,0,24,28,4194312 又代表什么?                  以下是sysdatabases在联机帮助中的说明:
状态位,其中某些状态位可由用户使用 sp_dboption(read only、dbo use only、single user 等)进行设置: 
1 = autoclose;使用 sp_dboption 设置。-----请问2:直接把status改成1就行了,sp_dboption 是设置什么的4 = select into/bulkcopy;使用 sp_dboption 设置。
8 = trunc. log on chkpt;使用 sp_dboption 设置。
16 = torn page detection,使用 sp_dboption 设置。
32 = loading。
64 = pre recovery。
128 = recovering。
256 = not recovered。
512 = offline;使用sp_dboption 设置。
1024 = read only;使用 sp_dboption 设置。
2048 = dbo use only;使用
sp_dboption 设置。
4096 = single user;使用 sp_dboption 设置。
32768 = emergency mode。
4194304 = autoshrink。
1073741824 = cleanly shutdown。可以同时打开多个位。请问3:这句话怎么理解
                Go
                sp_configure 'allow updates', 0                        请问4:0代表可更新还是不可更新?sp_configure更改的是一个数据库的还是所有数据库的                reconfigure with override
                Go

解决方案 »

  1.   


    USE   MASTER   
    GO   
    SP_CONFIGURE 'ALLOW UPDATES',1
    GO
    ---试试重启服务可行,不行执行下面的..
    RECONFIGURE WITH OVERRIDE   
    GO   
    UPDATE SYSDATABASES SET STATUS =32768 WHERE NAME='置疑的数据库名'   
    Go   
    sp_dboption '置疑的数据库名','single user','true'   
    Go   
    DBCC CHECKDB('置疑的数据库名')     
    Go   
    update sysdatabases set status=28 where name='置疑的数据库名'   
    Go   
    sp_configure 'allow updates',0
    GO
    reconfigure with override   
    Go     
    sp_dboption '置疑的数据库名', 'single user','false'   
      

  2.   

    sp_dboption  是显示或更改数据库选项的,你在查询分析器一运行就知道 要多个选项打开时只要相加sp_configure 显示或更改当前服务器的全局配置设置
      

  3.   

    sp_configure是更新整个数据库服务器的选项sp_configure 'allow updates', 0 代表系统表不可更新sp_dboption 是设置数据库选项的,不过有些选项必须通过修改系统表来实现
      

  4.   

    下边是运行结果,只有一列,怎么更改?
    ANSI null default
    ANSI nulls
    ANSI padding
    ANSI warnings
    arithabort
    auto create statistics
    auto update statistics
    autoclose
    autoshrink
    concat null yields null
    cursor close on commit
    db chaining
    dbo use only
    default to local cursor
    merge publish
    numeric roundabort
    offline
    published
    quoted identifier
    read only
    recursive triggers
    select into/bulkcopy
    single user
    subscribed
    torn page detection
    trunc. log on chkpt.
      

  5.   

    sp_dboption '置疑的数据库名', '选项名称','false'  --就像这样
      

  6.   

    那我怎么看sp_dboption 各项 是 false 还是 true 呢?毕竟只有一列