Quantcast
Channel: OracleDB – The Wiert Corner – irregular stream of stuff
Viewing all articles
Browse latest Browse all 20

Oracle alter table drop column tips: unused columns

$
0
0

An interesting tip at alter table drop column tips for Oracle: unused columns.

I knew about the multi-column syntax for drop column, but the unused columns:

You can also drop a table column by marking it unused and then dropping the column, thusly:

alter table
    table_name
set unused column
    column_name
;

They will appear in the DBA_UNUSED_COL_TABS view.

After that:

alter table
    table_name
drop unused columns
;

You can perform the first statement for a few columns over time, then the last statement will delete them all.

Together with some other views like described in places like oracle – How to check if a column exists before adding it to an existing table in PL/SQL?, you can create nifty scripts for your meta-data maintenance.

–jeroen

via: alter table drop column tips.


Filed under: Database Development, Development, OracleDB

Viewing all articles
Browse latest Browse all 20

Trending Articles