Is it possible to change a columns name

Started by Wim Ceulemansabout 27 years ago5 messagesgeneral
Jump to latest
#1Wim Ceulemans
wim.ceulemans@nice.be

Hi

Is there a simple way to change the name of a column? In addtion, is it
possible to change a column from 'null' to 'not null' and vice versa?

TIA
Wim Ceulemans - wim.ceulemans@nice.be
Nice Software Solutions www.nice.be
Eglegemweg 3, 2811 Hombeek - Belgium
Tel +32(0)15 41 29 53 - Fax +32(0)15 41 29 54

#2Bruce Momjian
bruce@momjian.us
In reply to: Wim Ceulemans (#1)
Re: [GENERAL] Is it possible to change a columns name

[Charset iso-8859-1 unsupported, filtering to ASCII...]

Hi

Is there a simple way to change the name of a column? In addtion, is it
possible to change a column from 'null' to 'not null' and vice versa?

alter table classname1 [*]
rename [column] attname1 to attname2

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#3Pavel PaJaSoft Janousek
janousek@fonet.cz
In reply to: Bruce Momjian (#2)
Re: [GENERAL] Is it possible to change a columns name

alter table classname1 [*]
rename [column] attname1 to attname2

It's good idea, but if I would change not the name, but properties for example :
create table pokus (col1 int, col2 varchar (20));

and now I would col1 as col1 int default 5 and col2 varchar (20) not null.
or col2 varchar (30)...

I search many MB of text about SQL etc., but I found only command for adding column or for the renaming it, but what about remove some column or change properties of column?

Thanx for any ideas....

Pavel PaJaSoft Janousek
FoNet, spol. s r.o.

#4Kevin Heflin
kheflin@shreve.net
In reply to: Pavel PaJaSoft Janousek (#3)
Re: [GENERAL] Is it possible to change a columns name

On Wed, 10 Mar 1999, Pavel PaJaSoft Janousek wrote:

alter table classname1 [*]
rename [column] attname1 to attname2

It's good idea, but if I would change not the name, but properties for example :
create table pokus (col1 int, col2 varchar (20));

and now I would col1 as col1 int default 5 and col2 varchar (20) not null.
or col2 varchar (30)...

I search many MB of text about SQL etc., but I found only command for
adding column or for the renaming it, but what about remove some
column or change properties of column?

I've run into this problem many times.. best answer I've found has been to
dump the database, recreate the table making any necessary changes, than
copy the data back in.

--------------------------------------------------------------------
Kevin Heflin | ShreveNet, Inc. | Ph:318.222.2638 x103
VP/Mac Tech | 333 Texas St #619 | FAX:318.221.6612
kheflin@shreve.net | Shreveport, LA 71101 | http://www.shreve.net
--------------------------------------------------------------------

#5Pavel PaJaSoft Janousek
janousek@fonet.cz
In reply to: Kevin Heflin (#4)
Re: [GENERAL] Is it possible to change a columns name

It's good idea, but if I would change not the name, but properties for example :
create table pokus (col1 int, col2 varchar (20));

and now I would col1 as col1 int default 5 and col2 varchar (20) not null.
or col2 varchar (30)...

I search many MB of text about SQL etc., but I found only command for
adding column or for the renaming it, but what about remove some
column or change properties of column?

I've run into this problem many times.. best answer I've found has been to
dump the database, recreate the table making any necessary changes, than
copy the data back in.

Yes, I do this always too, but I prefer SQL syntax before manual editing dumped database....

Have somebody any idea?

Pavel PaJaSoft Janousek
FoNet, spol. s r.o.