How we use these in sql [message #40823] |
Thu, 07 November 2002 07:49 |
Gurdeep Singh
Messages: 64 Registered: October 2002
|
Member |
|
|
In 8i how we query these to change the column name
1. ADD new columns
2. UPDATE new column with contents of old col
3. DROP old column using
why we use these two query
ALTER TABLE SET UNUSED COLUMN ;
ALTER TABLE DROP UNUSED COLUMNS;
|
|
|
Re: How we use these in sql [message #40840 is a reply to message #40823] |
Thu, 07 November 2002 09:47 |
Todd Barry
Messages: 4819 Registered: August 2001
|
Senior Member |
|
|
alter table t add (new_column number); -- or whatever datatype
update t set new_column = old_column;
alter table t drop (old_column);
The SET UNUSED command just hides the column from use - it doesn't actual remove the column (and data) from the table. The DROP UNUSED command actually drops any columns previously marked as UNUSED.
Usually, you can just DROP a column directly (without marking it UNUSED), but there are circumstances (high volume, etc.) where you don't want to immediately incur the overhead of the DROP - a SET UNUSED runs very fast. You can then DROP UNUSED at a more appropriate/convenient time.
|
|
|