The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

    • RT @BadAstronomer: And on top of it, this. IN THE MIDDLE OF A PANDEMIC. This is where anti-science takes us, folks. Right here. 2 hours ago
    • RT @isotopp: [Aquara Sensor] -> (zigbee) -> [zigbee2mqtt] -> -> [mqtt] -> (mosquitto) -> [mqtt] -> (python consumer) -> [http/influx] -> (i… 2 hours ago
    • RT @raoulbeunen: Zelfs in beschermd #Natura2000 gebied is de natuur niet veilig. In de uiterwaarden bij @Gem_Wageningen is het kruiden- en… 2 hours ago
    • RT @recursecenter: For the rest of 2020 we're running all of our batches online, which means that you can join RC from anywhere in the worl… 3 hours ago
    • RT @StevenGeurts: Ik vind er een zekere schoonheid in zitten dat het klimaat net zo duur blijkt te zijn als het overeind houden van een luc… 3 hours ago
  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,920 other followers

Oracle alter table drop column tips: unused columns

Posted by jpluimers on 2016/02/18

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: