祝愿大家身体健康!

 站点注册  找回密码
 站点注册

QQ登录

只需一步,快速开始

查看: 6367|回复: 8

先发个帖子问个问题

[复制链接]

先发个帖子问个问题

[复制链接]
wycking

主题

0

回帖

1

积分

新手上路

积分
1
贡献
在线时间
小时
2004-6-14 12:53:38 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?站点注册

×
我原本建立的数据库很大,现在觉得用不了那么多的空间,我想把它压缩小一点,该如何去做呢?
共享共进共赢Sharing And Win-win Results
SYBASEBBS - 免责申明1、欢迎访问“SYBASEBBS.COM”,本文内容及相关资源来源于网络,版权归版权方所有!本站原创内容版权归本站所有,请勿转载!
2、本文内容仅代表作者观点,不代表本站立场,作者自负,本站资源仅供学习研究,请勿非法使用,否则后果自负!请下载后24小时内删除!
3、本文内容,包括但不限于源码、文字、图片等,仅供参考。本站不对其安全性,正确性等作出保证。但本站会尽量审核会员发表的内容。
4、如本帖侵犯到任何版权问题,请立即告知本站 ,本站将及时删除并致以最深的歉意!客服邮箱:admin@sybasebbs.com
ehxz

主题

0

回帖

58万

积分

管理员

积分
588671
贡献
在线时间
小时
2004-6-14 13:16:34 | 显示全部楼层

SYBASE实现起来好象比较麻烦~~要重建表,然后把数据BCP一遍的样子。

其它的我也不懂了。

共享共进共赢Sharing And Win-win Results
wycking 楼主

主题

0

回帖

1

积分

新手上路

积分
1
贡献
在线时间
小时
2004-6-14 16:25:48 | 显示全部楼层
这么麻烦,真是郁闷!!!
共享共进共赢Sharing And Win-win Results
hchi0118

主题

0

回帖

4

积分

新手上路

积分
4
贡献
在线时间
小时
2004-7-7 15:57:51 | 显示全部楼层

把表、触发器和存储过程用ddl导出后再导到新库去,再用bcp导一下数据就可以了,不是太麻烦啊

[em05]
共享共进共赢Sharing And Win-win Results
guduxiao

主题

0

回帖

1

积分

新手上路

积分
1
贡献
在线时间
小时
2004-7-9 09:58:21 | 显示全部楼层
厉害啊!!!
共享共进共赢Sharing And Win-win Results
jesse411

主题

0

回帖

14

积分

新手上路

积分
14
贡献
在线时间
小时
2005-10-9 10:25:08 | 显示全部楼层
就是这样
共享共进共赢Sharing And Win-win Results
flybean

主题

0

回帖

595

积分

管理员

积分
595
贡献
在线时间
小时
2005-10-9 10:46:27 | 显示全部楼层
警告:本方法未经官方测试、官方认可。使用者自行承担一切后果!!!!

An Unsupported Method to Shrink a Database
This process is fairly trivial in some cases, such as removing a recently added fragment or trimming a database that has a log fragment as its final allocation, but can also be much more complicated or time consuming than the script and bcp method.
General Outline
The general outline of how to do it is:
1. Make a backup of the current database
2. Migrate data from sysusages fragments with high lstart values to fragments with low lstart values.
3. Edit sysusages to remove high lstart fragments that no longer have data allocations.
4. Reboot ASE.
Details
1. Dump your database. If anything goes wrong, you will need to recover from this backup!
2. Decide how many megabytes of space you wish to remove from your database.
3. Examine sysusages for the database. You will be shrinking the database by removing the fragments with the highest lstart values. If the current fragments are not of appropriate sizes, you may need to drop the database, recreate it so there are more fragments, and reload the dump.
A trivial case: An example of a time when you can easily shrink a database is if you have just altered it and are sure there has been no activity on the new fragment. In this case, you can directly delete the last row in sysusages for the db (this row was just added by alter db) and reboot the server and it should come up cleanly.
4. Change the segmaps of the fragments you plan to remove to 0. This will prevent future data allocations to these fragments.
Note: If any of the fragments you are using have user defined segments on them, drop those segments before doing this.
sp_configure "allow updates", 1
go
reconfigure with override -- not necessary in System 11
go
update sysusages
set segmap = 0
where dbid = <dbid>
and lstart = <lstart>
go
dbcc dbrepair(<dbname>, remap)
go
Ensure that there is at least one data (segmap 3) and one log (segmap 4) fragment, or one mixed (segmap 7) fragment.
If the server has been in use for some time, you can shrink it by deleting rows from sysusages for the db, last rows first, after making sure that no objects have any allocations on the usages.
5. Determine which objects are on the fragments you plan to remove.
traceon(3604)
go
dbcc usedextents( dbid,0,0,1)
go
Find the extent with the same value as the lstart of the first fragment you plan to drop. You need to migrate every object appearing from this point on in the output.
6. Migrate these objects onto earlier fragments in the database.
Objids other than 0 or 99 are objects that you must migrate or drop. You can migrate a user table by building a new clustered index on the table (since the segmap was changed, the new allocations will not go on this fragment).
You can migrate some system tables (but not all) using the sp_fixindex command to rebuild its clustered index. However, there are a few system tables that cannot have their clustered indexes rebuilt, and if they have any allocations on the usage, you are out of luck.
If the objid is 8, then it is the log. You can migrate the log by ensuring that another usage has a log segment (segmap 4 or 7). Do enough activity on the database to fill an extents worth of log pages, then checkpoint and dump tran.
Once you have moved all the objects, delete the row from sysusages and reboot the server.
Run dbcc checkdb and dbcc checkalloc on the database to be sure you are ok, then dump the database again.

[此贴子已经被作者于2005-10-10 10:50:17编辑过]
共享共进共赢Sharing And Win-win Results
flybean

主题

0

回帖

595

积分

管理员

积分
595
贡献
在线时间
小时
2005-10-10 10:45:56 | 显示全部楼层

警告:以下方法未经官方测试、官方认可,使用者自行承担责任!!

An Unsupported Method to Shrink a Database

This process is fairly trivial in some cases, such as removing a recently added fragment or trimming a database that has a log fragment as its final allocation, but can also be much more complicated or time consuming than the script and bcp method.

General Outline

The general outline of how to do it is:

  1. Make a backup of the current database
  2. Migrate data from sysusages fragments with high lstart values to fragments with low lstart values.
  3. Edit sysusages to remove high lstart fragments that no longer have data allocations.
  4. Reboot ASE.

Details

  1. Dump your database. If anything goes wrong, you will need to recover from this backup!
  2. Decide how many megabytes of space you wish to remove from your database.
  3. Examine sysusages for the database. You will be shrinking the database by removing the fragments with the highest lstart values. If the current fragments are not of appropriate sizes, you may need to drop the database, recreate it so there are more fragments, and reload the dump.
    A trivial case: An example of a time when you can easily shrink a database is if you have just altered it and are sure there has been no activity on the new fragment. In this case, you can directly delete the last row in sysusages for the db (this row was just added by alter db) and reboot the server and it should come up cleanly.
  4. Change the segmaps of the fragments you plan to remove to 0. This will prevent future data allocations to these fragments.
    Note: If any of the fragments you are using have user defined segments on them, drop those segments before doing this.
    sp_configure "allow updates", 1
    go
    reconfigure with override -- not necessary in System 11
    go
    update sysusages
    set segmap = 0
    where dbid = <dbid>
    and lstart = <lstart>
    go
    dbcc dbrepair(<dbname>, remap)
    go
    Ensure that there is at least one data (segmap 3) and one log (segmap 4) fragment, or one mixed (segmap 7) fragment.
    If the server has been in use for some time, you can shrink it by deleting rows from sysusages for the db, last rows first, after making sure that no objects have any allocations on the usages.
  5. Determine which objects are on the fragments you plan to remove.
    traceon(3604)
    go
    dbcc usedextents( dbid,0,0,1)
    go
    Find the extent with the same value as the lstart of the first fragment you plan to drop. You need to migrate every object appearing from this point on in the output.
  6. Migrate these objects onto earlier fragments in the database.
    Objids other than 0 or 99 are objects that you must migrate or drop. You can migrate a user table by building a new clustered index on the table (since the segmap was changed, the new allocations will not go on this fragment).
    You can migrate some system tables (but not all) using the sp_fixindex command to rebuild its clustered index. However, there are a few system tables that cannot have their clustered indexes rebuilt, and if they have any allocations on the usage, you are out of luck.
    If the objid is 8, then it is the log. You can migrate the log by ensuring that another usage has a log segment (segmap 4 or 7). Do enough activity on the database to fill an extents worth of log pages, then checkpoint and dump tran.
    Once you have moved all the objects, delete the row from sysusages and reboot the server.
    Run dbcc checkdb and dbcc checkalloc on the database to be sure you are ok, then dump the database again.
共享共进共赢Sharing And Win-win Results
xxgsymj

主题

0

回帖

70

积分

注册会员

积分
70
贡献
在线时间
小时
2005-11-4 09:07:55 | 显示全部楼层

嘿嘿

俺也想当初那样整 结果缩不小

所以俺就自己建了个库 先建表 再用公司自己的一个应用(就相当于数据管道之类的) 把数据分别导进来 呵呵,,很快的

共享共进共赢Sharing And Win-win Results
您需要登录后才可以回帖 登录 | 站点注册

本版积分规则

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com

QQ|Archiver|PowerBuilder(PB)BBS社区 ( 鲁ICP备2021027222号-1 )

GMT+8, 2024-11-24 11:16 , Processed in 0.150063 second(s), 10 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表