|
|
| Author |
Message |
rsshanmugam
Active User
Joined: 08 Mar 2005 Posts: 53 Location: Chennai
|
|
|
|
As everyone knows we cant drop column in db2 but in one of my interview they asked why cant we drop column in db2.
can anyone please answer my question. |
|
| Back to top |
|
 |
References
|
|
 |
ovreddy
Active User
Joined: 06 Dec 2004 Posts: 200 Location: Keane India Ltd., Hyderabad
|
|
|
|
Hi,
The answer to your question is no. The only way to remove a column from an existing table is to DROP that table, and then re-CREATE it without the column you no longer require. As you correctly note, that means that all dependent tables, data, indexes, authorization, etc. will also be dropped. That is why there are DBA tools on the market that automate the process of dropping and then re-creating all of the impacted objects and data. One such tool is BMC Software's Change Manager.
You'd probably be better off just leaving the column there, but not using it. Of course, that could lead to confusion as people see the column and expect the data to be not only there, but accurate. You might consider creating a view that contains all of the columns except the one you wish to remove. Then assign your users and programmers authority to use the view, instead of the base table.
Thanks,
Reddy |
|
| Back to top |
|
 |
pkmainframe
New User
Joined: 14 Jun 2005 Posts: 19 Location: India
|
|
|
|
Hi,
Answer to your question is no, either you drop the table, or create a new table/view excluding the column.
Tx
pk |
|
| Back to top |
|
 |
|
|
|