Re: How to change column names?

From: turum <pepe_at_tid.es>
Date: 1998/09/25
Message-ID: <01bde869$5b2fa0a0$b031a8c0_at_sg157pcs>#1/1


There is a faster method, but be careful with it. I think it is very interesting when you "must" rename a column of a large table.

UPDATE col$ SET name = '&new_name'
WHERE (name = '&old_name') and

             (obj# = (SELECT obj# FROM obj$
                         WHERE (name = '&table_name') and
                                      (owner# = (SELECT user# FROM user$
                                                      WHERE name =
'&user'))));
To reflect the change in system views, you should run catalog and catproc.

It is very important to drop any indexes, foreing keys and primary constraints that might be on the column. These can be re-created later.

Cheers

aaronurbain_at_bigfoot.com escribió en artículo <6ueof2$ge4$1_at_nnrp1.dejanews.com>...
> In article <6u6t6v$a2b$1_at_nnrp1.dejanews.com>,
> badstreetboy_at_my-dejanews.com wrote:
> > I know 'alter table' can add column or change datatype of a column.
 But can
> > it change column name?
> >
> > Thanks..
> >
> > -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> > http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
> >
>
> no. rename the table, create the table with the new name, and
 insert(select).
> dont forget your constraints, grants and triggers.
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
>
Received on Fri Sep 25 1998 - 00:00:00 CEST

Original text of this message