Re: The best to alter table, need help
Posted in 1998
scotts@tibco.com wrote:
>
> Hi there,
> I'm currently maintaining a database
> need to do lots of table changes. I like to know the best way to do it.
>
> Suppose the table is
>
> Table
> ( A1 int,
> A2 char(10),
> A3 varchar(10)
> )
>
> 1, I want to ADD one field A4 smallint, between A2 and A3, how?
> Table
> ( A1 int,
> A2 char(10),
> A4 smallint,
> A3 varchar(10)
> )
>
> 2,
> I want to delete A2, how?
> Table
> ( A1 int,
> A3 varchar(10)
> )
ALTER TABLE Table ADD (A4 SMALLINT BEFORE A3), DROP (A2);
> 3,
> I want to rename A3 to A9, how?
> Table
> ( A1 int,
> A2 char(10),
> A9 varchar(10)
> )
RENAME COLUMN Table.A3 TO A9;
Double check the syntax of both statements; BEFORE might be AFTER,
for example, and TO might be AS, and although you can do composite
ALTER TABLE statements, I might not have every character of thestatement correct.
> Please reply to sjsyau@yahoo.com
No -- it isn't in the Reply-To field, so I won't; I don't type
other people's email addresses for them.
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN
#include <disclaimer.h>