View previous topic :: View next topic
|
Author |
Message |
keerthi
New User
Joined: 23 Mar 2005 Posts: 25
|
|
|
|
Can we delete a column from the table if yes wat is the query
Thanks in advance,
keerthi. |
|
Back to top |
|
|
MGIndaco
Active User
Joined: 10 Mar 2005 Posts: 432 Location: Milan, Italy
|
|
|
|
Do you want delete all the record of a table or you want delete the column?
If you want delete all the rows of a column you must update all the record for that column erasing so its value.
If you want delete the column you must ALTER the table and DROP the column you desire as you can see below:
Code: |
ALTER TABLE mytable
DROP COLUMN mycolumn |
But it's a danger solution if you don't know its refereces...
Look before you drop if it is a PRIMARY or FOREING KEY! |
|
Back to top |
|
|
David P
Active User
Joined: 11 Apr 2005 Posts: 106 Location: Cincinnati Ohio
|
|
|
|
Hi MGIndaco,
Correct me if I am wrong but I believe it won't allow to drop a column if it is primary key.
regards,
david. |
|
Back to top |
|
|
raguibmm
New User
Joined: 16 Mar 2005 Posts: 4
|
|
|
|
ya it won 't allow |
|
Back to top |
|
|
MGIndaco
Active User
Joined: 10 Mar 2005 Posts: 432 Location: Milan, Italy
|
|
|
|
It's for this that I ask a control before process this alter |
|
Back to top |
|
|
babuprasad_g Currently Banned New User
Joined: 26 May 2005 Posts: 45 Location: gurgaon
|
|
|
|
Hi,
Better way is just Create Another Table and load The records from your previous table Then u can Drop Your table.
I hope this is the right way. |
|
Back to top |
|
|
jeroznishanth
New User
Joined: 21 Nov 2007 Posts: 8 Location: Bangalore
|
|
|
|
Code: |
ALTER TABLE CAT_MAIN34
DROP COLUMN REMARKS; |
MY TABLE IS CAT_MAIN34 AND THE COLUMN WHICH I WAN T TO REMOVE IS REMARKS. AND ITS NOT A PRIMARY OR FORIEGN KEY...
DINT WORK WITH ME.... PLZ HELP ME.... |
|
Back to top |
|
|
muthuvel
Active User
Joined: 29 Nov 2005 Posts: 217 Location: Canada
|
|
|
|
jeroznishanth,
Welcome to the Forum.
Do you have privilege to alter the table bcos it will be with DBAs only .Is it throwing any error ? |
|
Back to top |
|
|
jeroznishanth
New User
Joined: 21 Nov 2007 Posts: 8 Location: Bangalore
|
|
|
|
hai muthu,
actually i am learning mainframes nw... I created a file... so obviously i will hav all the rights... right?... if i am wrong just tell me...
Code: |
ALTER TABLE CAT_MAIN34
DROP COLUMN REMARKS; |
i gave this SQL in QMF... and it gave the error
Code: |
SQL error at or before REMARKS |
i hope that u can helo me out....
|
|
Back to top |
|
|
jeroznishanth
New User
Joined: 21 Nov 2007 Posts: 8 Location: Bangalore
|
|
|
|
that is " i created table".. |
|
Back to top |
|
|
naveensrimf
New User
Joined: 04 Oct 2005 Posts: 34
|
|
|
|
which version you are using? Upto Version 8 you can't drop the column in Table. Version 9 onwards you can drop the column from table.
Note: Before Drop the column you have analysie the impact of the Column. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
do You realize You replied to a three years and a half old topic ? |
|
Back to top |
|
|
|