|
 |
|
Oracle Database Tips by Donald Burleson |
Table Alteration
Face it, no one designs perfect
applications. This means we sometimes have to change things. For
tables, this means adding, changing, or dropping columns; adding
constraints; or even deleting all of the rows from the table. Let's
look at how to accomplish these table changes using the functions of
the Oracle8 ALTER TABLE command, which are to:
-
Add a column.
-
Add an integrity constraint.
-
Add integrity constraints to object-type
columns.
-
Add or modify index-only table
characteristics.
-
Add or modify LOB columns.
-
Add or modify object type, nested table
type, or varray type column for a table.
-
Add, modify, split, move, drop, or
truncate table partitions.
-
Add, modify, split, move, drop, or
truncate table subpartitions.
-
Allow or disallow writes to a table.
-
Change the rows per block of storage for
a table.
-
Drop a column.
-
Enable, disable, or drop an integrity
constraint or trigger.
-
Explicitly allocate an extent.
-
Explicitly deallocate the unused space
of a table.
-
Modification of the degree of
parallelism for a table
-
Modify the LOGGING/NOLOGGING attributes.
-
Modify the real storage attributes of a
nonpartitioned table or the default attributes of a partitioned
table.
-
Modify the storage characteristics or
other parameters.
-
Physically move a table.
-
Redefine a column (datatype, size,
default value).
-
Rename a table or a table partition.
-
In order to use the ALTER TABLE command
in Oracle, the following must be true:
-
The table must be in your own schema,
you must have ALTER privilege on the table, or you must have
ALTER ANY TABLE system privilege.
-
To use an object type in a column
definition when modifying a table, either that object must
belong to the same schema as the table being altered or you must
have either the EXECUTE ANY TYPE system or the EXECUTE schema
object privilege for the object type.
-
If you are using Trusted Oracle in DBMS
MAC mode, your DBMS label must match the table's creation label
or you must satisfy one of the following criteria:
a. If the table's creation label is
higher than your DBMS label, you must have READUP and WRITEUP
system privileges.
b. If the table's creation label is
lower than your DBMS label, you must have the WRITEDOWN system
privilege.
c. If the table's creation label and
your DBMS label are not comparable, you must have READUP,
WRITEUP, and WRITEDOWN system privileges.
See Code Depot

www.dba-oracle.com/oracle_scripts.htm |