5

我正在尝试创建一个打印消息然后创建表的 PL/SQL 脚本。

如果我在 SqlPlus 中运行脚本,则会打印消息,创建表,但我收到一条错误消息,指出表正在使用中。似乎“创建表”运行了两次。在 SQLDeveloper 中我没有错误。

这是我的脚本:

set serveroutput on

begin
  dbms_output.Put_line('running test.sql');
end;
/
create table my_table
(
  name varchar2(100) not null
);
/

这是输出:

SQL> @test.sql
running test.sql

PL/SQL procedure successfully completed.

Table created.

create table my_table
             *
ERROR at line 1:
ORA-00955: name is already used by an existing object    

SQL>

我做错了什么?

提前致谢。

4

1 回答 1

-1

将您的脚本更改为:

set serveroutput on
begin
   dbms_output.Put_line('running test.sql');
   create table my_table
   (
     name varchar2(100) not null
   );
end
/
于 2018-11-07T18:16:48.740 回答