尝试更改SQL块中的表时出现错误

编程入门 行业动态 更新时间:2024-10-27 18:17:40
本文介绍了尝试更改SQL块中的表时出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建一个test.sql文件,并放入其中:

I create a test.sql file and inside I put:

begin alter table table1 enable row movement; alter table table1 shrink space; end; /

这是不允许的吗?因为出现错误:

Is this not allowed? Because I get error:

Encountered the symbol "ALTER" when expecting one of the following: begin case declare exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe

推荐答案

您不能在PL/SQL块中将DDL作为静态SQL发布.如果要将这些命令放在PL/SQL块中,则需要使用动态SQL,即

You cannot issue DDL as static SQL in a PL/SQL block. If you want to put those commands in a PL/SQL block, you'd need to use dynamic SQL, i.e.

BEGIN EXECUTE IMMEDIATE 'alter table table1 enable row movement'; EXECUTE IMMEDIATE 'alter table table1 shrink space cascade'; END; /

但是,仅发出连续的SQL语句而不是发出单个PL/SQL块可能更容易.

It may be easier, however, to just issue consecutive SQL statements rather than issuing a single PL/SQL block.

更多推荐

尝试更改SQL块中的表时出现错误

本文发布于:2023-11-25 01:00:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627671.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:出现错误   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!