I have a specific scenario where i have to insert two new columns in an existing table in Oracle. I can not do the dropping and recreating the table. So can it be achieved by any means??
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Amit-
I don’t believe you can add a column anywhere but at the end of the table once the table is created. One solution might be to try this:
Drop the table you want to add columns to:
It’s at the point you could rebuild the existing table from scratch adding in the columns where you wish.
Let’s assume for this exercise you want to add the columns named “COL2 and COL3”.
Now insert the data back into the new table:
When the data is inserted into your “new-old” table, you can drop the temp table.
This is often what I do when I want to add columns in a specific location. Obviously if this is a production on-line system, then it’s probably not practical, but just one potential idea.
-CJ