Home » SQL & PL/SQL » SQL & PL/SQL » delete several columns from a table
delete several columns from a table [message #211518] Fri, 29 December 2006 01:51 Go to next message
steffeli
Messages: 112
Registered: July 2006
Senior Member
How can I drop the columns P1, P2 and P3 from table tab?

I tried

alter table tab drop column P1, P2, P3


and

alter table tab drop P1, P2, P3


but it does not work. What's wrong?

Thanks
Stefan
Re: delete several columns from a table [message #211521 is a reply to message #211518] Fri, 29 December 2006 02:04 Go to previous messageGo to next message
hobbes
Messages: 173
Registered: January 2006
Senior Member
alter table tab drop (P1, P2, P3);
Re: delete several columns from a table [message #211522 is a reply to message #211518] Fri, 29 December 2006 02:07 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Not tested, but if I read the docs well, you should use
drop (column,column)

But frankly, I cannot imagine why you would go through the trouble of posting a message here, waiting for a reply etc. when you can also execute multiple drop statements.
It is not like you drop columns everyday, requiring you to know this by heart...
icon14.gif  Re: delete several columns from a table [message #211693 is a reply to message #211518] Mon, 01 January 2007 05:14 Go to previous messageGo to next message
nabbu
Messages: 5
Registered: December 2006
Junior Member
If you need to delete all data from all three
columns c1,c2,c3 then alter command donot work
with DROP option. Instead you should UPDATE
the req table as follows:=


UPDATE emp set c1=null;
UPDATE emp set c2=null;
UPDATE emp set c3=null;

bye
Re: delete several columns from a table [message #211696 is a reply to message #211693] Mon, 01 January 2007 05:45 Go to previous message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Why three separate statements? Why wouldn't you put it into one?
UPDATE emp SET
  c1 = null,
  c2 = null,
  c3 = null;

But, @steffeli wants to DROP those columns, not empty them.

[Updated on: Mon, 01 January 2007 05:47]

Report message to a moderator

Previous Topic: CBO and multiple paths
Next Topic: Build custom sum function
Goto Forum:
  


Current Time: Fri Dec 09 13:42:11 CST 2016

Total time taken to generate the page: 0.08721 seconds