Solved

Oracle Version, TOAD VI and Drop Column

Posted on 2004-10-14
11
4,856 Views
Last Modified: 2007-12-19
Hi,

I'm trying to delete a column from an Oracle database... I know there's a SQL command to do this, but only for version 8i and newer.  So, my questions are:

1.- How can I retrieve the version of my Oracle DB using TOAD (you know, using only SQL)
2.- If my version is older than 8i, how do I drop the column

That's about it.
Thanks!

TCV
0
Comment
Question by:Taconvino
  • 6
  • 5
11 Comments
 
LVL 23

Expert Comment

by:seazodiac
ID: 12310025
1. that will be :

select * from v$version;


2. alter table <table_name> drop column <column_name>;

0
 
LVL 6

Author Comment

by:Taconvino
ID: 12310065
OK! Now I got the version, but when I run the Alter, I get this error message:

The following error has occurred:

ORA-00905: missing keyword

And leaves the word "column" selected.
So, I guess the command doesn't work for Oracle8 Release 8.0.4.0.0.  Please, any other help would be great!

TCV
0
 
LVL 23

Accepted Solution

by:
seazodiac earned 500 total points
ID: 12310100
as you said, the drop column does not work for oracle8.

the workaround is to recreate :

create table <new_table_name> as
select col1, col2, ...coln          --DON'T include the column-to-be-dropped
from <table_name>;


additionally, you have to put back in all the constraints and indexes, sequences and synonyms;
0
 
LVL 23

Expert Comment

by:seazodiac
ID: 12310116
There is another way:

you can create a VIEW on top of that table:

create view <new_view_name>
as
select col1, col2, ....coln --Exclude the column-to-be-dropped
from <table_name>;


and direct users to use this view instead of this table.


I like this option better, because it does not disrupt your table structure and don't need to re-create all the constraints.
0
 
LVL 6

Author Comment

by:Taconvino
ID: 12310119
So, I have to recreate the table with a new name, then drop the old table, and then rename the new table, right?  Does the rename command work for Oracle8?

TCV
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 23

Expert Comment

by:seazodiac
ID: 12310126
Nope
0
 
LVL 6

Author Comment

by:Taconvino
ID: 12310175
Hummm... that leaves me right in the start, right?  Any way, I can do the same process twice to get where I want.  The view could be better, under other circumstances... anyway, Thanks!

TCV
0
 
LVL 23

Expert Comment

by:seazodiac
ID: 12310199
taconvino:

Rename table actually works in Oracle8 .It's getting rusty on me...I havenot used 8 for coon's age.
0
 
LVL 6

Author Comment

by:Taconvino
ID: 12314424
You're kidding!  Can you post the correct syntax please?  Thanks!

TCV
0
 
LVL 23

Expert Comment

by:seazodiac
ID: 12314647
easy:
just

rename <table_name> to <new_table_name>;


alter table <table_name> rename to <new_table_name>;
0
 
LVL 6

Author Comment

by:Taconvino
ID: 12328625
I'll check this on monday.  Thanks again!

TCV
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle DATE Column Space 11 63
case statement in where clause 5 42
Best RAID for a BDD Oracle 4 62
Use of Exception to end a Loop 3 17
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now