oracle 临时表 sybase,在sybase中创建临时表

本文探讨了在SQL批处理过程中遇到的临时表创建错误,特别是当试图创建已存在的临时表时。错误消息显示为'Cannot create temporary table...is already in use by another temporary table'。解决方案包括在创建前检查表是否存在并删除,或者确保每个创建命令在独立的批处理中。
摘要由CSDN通过智能技术生成

注:关于比格达多的第一个建议的更多信息。。。

先前的

#temp_table

当提交批处理时,已经存在,然后编译

create table

命令将生成错误。此行为可以在以下示例中看到:

create table #mytab (a int, b varchar(30), c datetime)

go

-- your code snippet; during compilation the 'create table' generates the error

-- because ... at the time of compilation #mytab already exists:

if object_id('#mytab') is not NULL

drop table #mytab

create table #mytab (a int, b varchar(30), c datetime)

go

Msg 12822, Level 16, State 1:

Server 'ASE200', Line 3:

Cannot create temporary table '#mytab'. Prefix name '#mytab' is already in use by another temporary table '#mytab'.

-- same issue occurs if we pull the 'create table' into its own batch:

create table #mytab (a int, b varchar(30), c datetime)

go

Msg 12822, Level 16, State 1:

Server 'ASE200', Line 1:

Cannot create temporary table '#mytab'. Prefix name '#mytab' is already in use by another temporary table '#mytab'.

-- test/drop the table in one batch:

if object_id('#mytab') is not NULL

drop table #mytab

go

-- create the table in a new batch; during compilation we don't get an error

-- because #mytab does not exist at this point:

create table #mytab (a int, b varchar(30), c datetime)

go

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值