为了账号安全,请及时绑定邮箱和手机立即绑定

“tempdb”数据库中的多语句事务中不允许使用“CREATE TABLE”命令

“tempdb”数据库中的多语句事务中不允许使用“CREATE TABLE”命令

白猪掌柜的 2023-06-21 16:36:43
我正在开发 java 项目,其中使用Sybase 和 Apache Metamodel来获取表数据及其信息。现在“ ddl in tran ”选项为 true,但当我使用 Apache Metamodel 获取列详细信息时,它仍然给我错误:com.sybase.jdbc4.jdbc.SybSQLException:“tempdb”数据库中的多语句事务中不允许使用“CREATE TABLE”命令。我在 Windows 10 上安装了 Sybase ASE 15.5。
查看完整描述

2 回答

?
开心每一天1111

TA贡献1836条经验 获得超13个赞

“ddl in tran”选项在临时数据库中也需要“打开”。系统管理员或具有 sa_role 的人可以这样做:


1> use master

2> go

1> sp_dboption tempdb, 'ddl in tran', 'true'

2> go

Warning: Attempting to change database options for a temporary database. Database options must be kept consistent across all temporary databases.

Database option 'ddl in tran' turned ON for database 'tempdb'.

Running CHECKPOINT on database 'tempdb' for option 'ddl in tran' to take effect.

(return status = 0)

正如警告所暗示的那样,如果您有多个临时数据库,这需要在所有临时数据库中保持一致。命令完成后,可以使用 sp_helpdb 检查选项:


1> sp_helpdb

2> go


[stuff deleted]


 tempdb                            104.0 MB              sa             2      Aug 05, 2019             no_recovery                     0               NULL        

 select into/bulkcopy/pllsort, trunc log on chkpt, ddl in tran, mixed log and data, allow wide dol rows 

下面是在事务中创建表的示例:


1> use tempdb

2> go

1> begin tran

2> go

1> create table foo ( k int not null, value varchar(25) null) 

2> go

1> commit

2> go

1> 


查看完整回答
反对 回复 2023-06-21
?
牧羊人nacy

TA贡献1862条经验 获得超7个赞

可以使用 (sp_dboption tempdb, 'ddl in tran', 'true'),但将其设置为 true 并不是一个好的做法,它可能会导致 tempdb 中的并发问题。

使用该选项必须小心。


查看完整回答
反对 回复 2023-06-21
  • 2 回答
  • 0 关注
  • 132 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信