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
The basic syntax of an ALTER TABLE command to add a NOT NULL constraint to a column in a table is as follows. ALTER TABLE table_name MODIFY column_name datatype NOT NULL; The basic syntax of ALTER TABLE to ADD UNIQUE CONSTRAINT to a table is as follows.
ALTER TABLE table_name RENAME TO new_table_name; Columns can be also be given new name with the use of ALTER TABLE. QUERY: Change the name of column NAME to FIRST_NAME in table Student.
Use the RENAME COLUMN statement to rename a column in a table. The RENAME COLUMN statement allows you to rename an existing column in an existing table in any schema (except the schema SYS). To rename a column, you must either be the database owner or the table owner.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With