Getting error while trying to alter table in an sql block
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 de开发者_开发百科clare 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
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;
/
It may be easier, however, to just issue consecutive SQL statements rather than issuing a single PL/SQL block.
精彩评论