?
Solved

delete/rename column in oracle 8i

Posted on 2003-03-24
5
Medium Priority
?
40,792 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
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

616 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