Home » SQL & PL/SQL » SQL & PL/SQL » how to delete rows of one column from table
how to delete rows of one column from table [message #196559] Thu, 05 October 2006 22:38 Go to next message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
sir,
how to delete rows of one column (i.e salary from emp table) from table.
thanx Cool
Re: how to delete rows of one column from table [message #196564 is a reply to message #196559] Thu, 05 October 2006 23:44 Go to previous messageGo to next message
rameshuddaraju
Messages: 69
Registered: June 2005
Location: India
Member

You can't delete a column's data unless you remove the column.
But, you can make the columns data as null if there are no constraints on that column

try this to make a columns data null

update emp set sal = null;


Ramesh
Re: how to delete rows of one column from table [message #196567 is a reply to message #196559] Fri, 06 October 2006 00:24 Go to previous messageGo to next message
asherisfine
Messages: 63
Registered: June 2006
Location: India
Member
Hi ashish

if you want to remove the column sal from emp permanently there are two other ways
1) Alter table emp drop column sal;


2) alter table emp set unused column sal;

This option will keep the column sal but then it is as good as it is not present. The only operation allowed on column after setting it as unused is to DROP it using first choice.


3) well if you don't want to drop the column sal but you just want to delete the values in the column sal then you should be using

Update emp set sal=NULL
as given by earlier reply
Re: how to delete rows of one column from table [message #196806 is a reply to message #196567] Sat, 07 October 2006 11:23 Go to previous message
Mohammad Taj
Messages: 2412
Registered: September 2006
Location: Dubai, UAE
Senior Member

SQL> alter table toto drop unused columns;

Table altered.


when u mark unused column in table then u drop after with above statement.
thanx
Previous Topic: some just table names after dropping demo tables
Next Topic: Export of schema
Goto Forum:
  


Current Time: Mon Dec 02 08:34:30 CST 2024