?
Solved

delete/rename column in oracle 8i

Posted on 2003-03-24
5
Medium Priority
?
40,697 Views
Last Modified: 2011-08-18
hello guys,
is it possible for me to delete or rename the column name in the table (oracle 8i). if that possible, can anyone give the idea on how to do it.

TQ
0
Comment
Question by:parameter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 3

Expert Comment

by:patelgokul
ID: 8200389
You can rename a column using the CREATE TABLE command with the AS clause. For example, the following statement re-creates the table STATIC, renaming a column from OLDNAME to NEWNAME:

CREATE TABLE temporary (newname, col2, col3)
    AS SELECT oldname, col2, col3 FROM static
DROP TABLE static
RENAME temporary TO static;

0
 
LVL 5

Accepted Solution

by:
jpkemp earned 200 total points
ID: 8207917
patelgokul's method will work.

This might take up less storage space:

ALTER TABLE mytable ADD newcolumn <datatype>;
UPDATE mytable SET newcolumn = oldcolumn;
COMMIT;
ALTER TABLE mytable DROP (oldcolumn);

(if the column is to be NOT NULL, do an "ALTER TABLE mytable MODIFY (newcolumn NOT NULL)")

Jeff
0
 

Expert Comment

by:theuser
ID: 11012838
try this:

alter table <table_name> rename column <old> to <new>;
0
 
LVL 5

Expert Comment

by:jpkemp
ID: 11150998
Note: The "rename column" syntax will work in Oracle 9i, not 8i.
0
 

Expert Comment

by:andoni2
ID: 11269998
And then only in 9.2 not in 9.0.1.
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question