Re: Changing the name of a column
Date: 1995/04/26
Message-ID: <3nm209$41p_at_eccdb1.pms.ford.com>#1/1
In article <D7LMKv.4Ao_at_CSUFresno.EDU>, stevec_at_zimmer.CSUFresno.EDU (Steve Cosner) writes:
|> >>
|> >>>
|> >>> Could somebody tell me how I would change the name of a column .
|> >>> Any help would be appreciated .
|> >>
|> >>You cannot do it directly or in one step. you can:
|> >>
|> >>1. use sqlplus COPY to create a new table with new column names,
|> >> then drop the old table and rename the new one; or
|> >>2. create a view with new column names, and a synonym of the view
|> >> which has the name of the original table and which yields the view.
|> >>--
|> >Or ...
|> >
|> >3. Add a new column to the existing table with the new name, use
|> >sqlplus to populate it, and then drop the old column.
|> >--
|>
|> My SQL Ref. Manual doesn't tell how to drop a column.
|> Can you post the command? I sure could use this feature!
|>
|>
|>
There is no sql command to drop a column use the step 1 stated above.
Say suppose You have a table foo_table with columns c1, c2, c3. You want to drop column c2.
- create table temp as select c1,c3 from foo_table;
- drop table foo_table;
- RENAME temp TO foo_table
The above three steps drop the column c2.
Say suppose You have a table foo_table with columns c1, c2, c3.If you want to change the name of column c3 to my_c3, do the following :
- create table temp(c1, c2, my_c3) as select c1,c2, c3 from foo_table;
- drop table foo_table;
- RENAME temp TO foo_table
Madhavi Lokam Received on Wed Apr 26 1995 - 00:00:00 CEST