如何关闭混合数据并登录Sybase ASE 15.7?

时间:2017-07-07 04:04:40

标签: sql sybase sybase-ase sybase-ase15

当我在Sybase ASE 15.7中使用sp_helpdb时,我的结果是:

db_abc      2054.0 MB   sa  trunc log on chkpt, mixed log and data
db_def      1030.0 MB   sa  trunc log on chkpt, mixed log and data

我可以关闭mixed log and data吗? 我试过sp_dboption db_abc , 'mixed log and data', false 但是显示错误Sybase Database Error: The database option does not exist or you cannot set the option.而在其他情况下sp_dboption db_abc , 'abort tran on log full', false是好的。

1 个答案:

答案 0 :(得分:1)

mixed log + data不是开关。它是数据库创建方式(以及页面在同一区域中的混合方式)的影响。您可以将其关闭。您需要将LOG与DATA分开才能实现目标。

由于在当前设备上,您需要具有LOG和DATA页面:

  • 添加仅计划用于日志(alter database .. log on ..
  • 的其他设备
  • 启用single user模式
  • 使用sp_logdevice过程
  • 将日志移至新创建的设备
  • 关闭single user模式

代码示例:

1> disk init name = dev1, physname = '/tmp/dev1.dat', size = '200M'
2> go
create database db_abc on dev1 = '200M'
2> go
CREATE DATABASE: allocating 102400 logical pages (200.0 megabytes) on disk 'dev1' (102400 logical pages requested).
Database 'db_abc' is now online.
1> exec sp_dboption 'db_abc', 'trunc log on chkpt', true
2> go
Database option 'trunc log on chkpt' turned ON for database 'db_abc'.
Running CHECKPOINT on database 'db_abc' for option 'trunc log on chkpt' to take effect.
(return status = 0)
1> exec sp_helpdb 'db_abc'
2> go
 name   db_size       owner dbid created      durability lobcomplvl inrowlen status                                 
 ------ ------------- ----- ---- ------------ ---------- ---------- -------- -------------------------------------- 
 db_abc      200.0 MB sa       4 Jul 07, 2017 full                0     NULL trunc log on chkpt, mixed log and data 

(1 row affected)

 device_fragments size          usage        created             free_kbytes      
 ---------------- ------------- ------------ ------------------- ---------------- 
 dev1                  200.0 MB data and log Jul  7 2017  9:56AM           202232 
(return status = 0)
1> disk init name = dev2, physname = '/tmp/dev2.dat', size = '100M'
2> go
1> alter database db_abc log on dev2 = '100M'
2> go
Extending database by 51200 pages (100.0 megabytes) on disk dev2
Warning: Using ALTER DATABASE to extend the log segment will cause user thresholds on the log segment within 128 pages of the last chance threshold to be disabled.
1> exec sp_dboption 'db_abc', 'single user', true
2> go
Database option 'single user' turned ON for database 'db_abc'.
Running CHECKPOINT on database 'db_abc' for option 'single user' to take effect.
(return status = 0)
1> exec sp_logdevice 'db_abc', 'dev2'
2> go
DBCC execution completed. If DBCC printed error messages, contact a user with System Administrator (SA) role.
DBCC execution completed. If DBCC printed error messages, contact a user with System Administrator (SA) role.
syslogs moved.
The last-chance threshold for database db_abc is now 16 pages.
(return status = 0)
1> exec sp_dboption 'db_abc', 'single user', false
2> go
Database option 'single user' turned OFF for database 'db_abc'.
Running CHECKPOINT on database 'db_abc' for option 'single user' to take effect.
(return status = 0)
1> exec sp_helpdb 'db_abc'
2> go
 name   db_size       owner dbid created      durability lobcomplvl inrowlen status                                 
 ------ ------------- ----- ---- ------------ ---------- ---------- -------- -------------------------------------- 
 db_abc      300.0 MB sa       4 Jul 07, 2017 full                0     NULL trunc log on chkpt, mixed log and data 

(1 row affected)

 device_fragments size          usage     created             free_kbytes      
 ---------------- ------------- --------- ------------------- ---------------- 
 dev1                  200.0 MB data only Jul  7 2017  9:56AM           202248 
 dev2                  100.0 MB log only  Jul  7 2017  9:57AM not applicable   

 -------------------------------------------------------------------------------------------------------------- 
 log only free kbytes = 102000                                                                                  
(return status = 0)