加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle – 尝试在sql块中更改表时获取错误

发布时间:2020-12-12 13:52:32 所属栏目:百科 来源:网络整理
导读:我创建一个test.sql文件,里面我放: beginalter table table1 enable row movement;alter table table1 shrink space;end;/ 这是不允许的?因为我收到错误: Encountered the symbol "ALTER" when expecting one of the following: begin case declare exit
我创建一个test.sql文件,里面我放:
begin
alter table table1 enable row movement;
alter table table1 shrink space;
end;
/

这是不允许的?因为我收到错误:

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,即
BEGIN
  EXECUTE IMMEDIATE 'alter table table1 enable row movement';
  EXECUTE IMMEDIATE 'alter table table1 shrink space cascade';
END;
/

但是,只需发出连续的SQL语句,而不是发出单个PL / SQL块可能会更容易。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读