我现在的数据库有10G大小,我估计里面碎片特别厉害,访问时非常慢,所以想整理一下,但网上的那些DBC的方法不行,要导入导出10G的数据要到什么时候呀,另外,我用什么方法可以压缩数据库呀

解决方案 »

  1.   

    我的Sybase测试服务器已经17G了,上次为了删除一个表里的无效内容(一个800万条数据的表),把日志空间都搞满了,好一个折腾才起来服务
      

  2.   

    bcp 出来再bcp回去了,最简单也最快捷。我的数据库有20几个,都再60G左右的,都是这样维护升级的。^_^
    select 'bcp VISDB..'+name+' out d:\data\'+name+'.txt'+
    ' -S 49 -U dba -P pasword-n '+
    '-e d:\log\'+name+'.log<br>pause<br>'
    from sysobjects 
    where type = 'U' and id not in(
    select b.id
    from sysobjects a, syscolumns b
    where a.id = b.id and a.type= 'U'
    and b.type = 63 and b.status = 128
    )
    union
    select 'bcp VISDB..'+name+' out d:\data\'+name+'.txt'+
    ' -S 49 -U dba -P password-n -E '+
    '-e d:\log\'+name+'.log<br>pause<br>'
    from sysobjects 
    where type = 'U' and id in(
    select b.id
    from sysobjects a, syscolumns b
    where a.id = b.id and a.type= 'U'
    and b.type = 63 and b.status = 128
    )
    自动生成bcp命令,然后自动处理带identity字段的表的identity问题,保证其前后一致。
    这是导出命令,导入命令只要在其中修改 out 为 in,得到命令后,用html浏览,拷贝下页面中
    显示的文件,到命令行运行就可以了