关于plsql命令行的问题

delphidj 2014-08-05 03:04:57
我在命令行中执行sql文件,文件中有以下一段一直会报错,但是在plsql的sql界面执行是没有问题的。
语句:

declare
tm_i integer:=0;
begin
select count(*) into tm_i from user_tables where lower(table_name) = lower('LOG_SYSINIT') ;
if tm_i>0 then
execute immediate ' drop table LOG_SYSINIT';
end if;
end;
/

create table LOG_SYSINIT
(
VC_USER VARCHAR2(30),
VC_LOGTEXT VARCHAR2(2000),
DT_LOGTIME TIMESTAMP(6)
)
tablespace ASSETDB
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64
minextents 1
maxextents unlimited
);
/


[color=#FF0000]错误信息:[/color]
Table created
create table LOG_SYSINIT
(
VC_USER VARCHAR2(30),
VC_LOGTEXT VARCHAR2(2000),
DT_LOGTIME TIMESTAMP(6)
)
tablespace ASSETDB
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64
minextents 1
maxextents unlimited
)
ORA-00955: 名称已由现有对象使用
...全文
264 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
引用 2 楼 delphidj 的回复:
to:z_shousi:直接drop table LOG_SYSINIT;是不行的 报错
我测试了你的代码可行的啊。你查询下 select count(*) from user_tables where lower(table_name) = lower('LOG_SYSINIT') ; 在你有表和无表的时候的取值呢。或者你在其中dbms_output下count的值看看。 --我勒个去,我竟然让你把ddl语句直接写出来,错了。
liao_z_j 2014-08-05
  • 打赏
  • 举报
回复
删除表和建表,分开执行,放两个文件
delphidj 2014-08-05
  • 打赏
  • 举报
回复
to:z_shousi:直接drop table LOG_SYSINIT;是不行的 报错
  • 打赏
  • 举报
回复
execute immediate ' drop table LOG_SYSINIT'; 直接改为 drop table LOG_SYSINIT;试试呢。

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧