如何通过批处理执行多个ddl字

发布于 2024-12-08 16:55:40 字数 1133 浏览 1 评论 0原文

当我部署我的asp.net应用程序时,我必须创建一些表空间/用户,我使用pqsql,但是我想知道有什么方法可以通过批处理创建它们吗?

例如,我可以执行这个ddl:

create tablespace TSA.....

然后我可以执行:

create user a ... default tablespace TSA...

但是当我同时执行它们时:

create tablespace TSA.....

create user a ... default tablespace TSA...

我会得到一个错误。

反正?

更新

错误是这样的:

ORA-02180: invalid CREATE TABLESPACE words

顺便说一句,我在 pl/sql 开发人员的 sql 窗口中运行 sql 批处理。

现在,我只想知道是否有任何方法可以运行整个 ddl sql 文件?

假设这是init.sql的内容:

create smallfile tablespace "DEV" datafile 'f:\app\administrator\oradata\orcl\dev01.dbf' size 100m autoextend on next 10m maxsize unlimited logging extent management local segment space management auto default nocompress


-- Create the user 
create user dev_sa
  identified by "000000"
  default tablespace DEV
  temporary tablespace TEMP;
-- Grant/Revoke role privileges 
grant connect to dev_sa;
grant dba to dev_sa;

--create another tablespace
--.....

如何在批处理模型中执行它?

When I deploy my asp.net application,I have to create some tablesapces/users,I use the pqsql,however I want to know is there any way I can create them with batch processing?

For example,I can execute this ddl:

create tablespace TSA.....

Then I can execute:

create user a ... default tablespace TSA...

But when I execute them at the same time:

create tablespace TSA.....

create user a ... default tablespace TSA...

I will get an error.

ANy way?

update

Error is something like this:

ORA-02180: invalid CREATE TABLESPACE words

BTW,I run the sql batches in the sql window of the pl/sql developer.

Now,I just want to know if there is any way I can run a whole ddl sql file?

Suppose this is the content of the init.sql:

create smallfile tablespace "DEV" datafile 'f:\app\administrator\oradata\orcl\dev01.dbf' size 100m autoextend on next 10m maxsize unlimited logging extent management local segment space management auto default nocompress


-- Create the user 
create user dev_sa
  identified by "000000"
  default tablespace DEV
  temporary tablespace TEMP;
-- Grant/Revoke role privileges 
grant connect to dev_sa;
grant dba to dev_sa;

--create another tablespace
--.....

How to execute it in the batch process model?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

说不完的你爱 2024-12-15 16:55:40

如果从 SQL*Plus 运行的文件中有两条语句,则需要使用 / 字符分隔语句,这也会导致执行每条语句

create tablespace TSA ...
/

create user a ... default tablespace TSA
/

(这是一个相当大的 'if ',当然按照 @APC 的评论;但是之前已经出现过 SQL Developer 中运行事物的不同方式,但实际上只是根据给出的最少信息进行的猜测......)

If you have the two statements in a file you're running from SQL*Plus, you need to separate the statements with the / character, which also causes each to be executed

create tablespace TSA ...
/

create user a ... default tablespace TSA
/

(That's quite a big 'if', of course as per @APC's comment; but is something that's come up before. As has different ways of running things in SQL Developer, among other things. But really no more than a guess from the minimal info given...)

带刺的爱情 2024-12-15 16:55:40

您的第一个 CREATE TABLE 末尾缺少分号 ;

You have a semi-colon ; missing off the end of your first CREATE TABLE

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文