Subject Re: Add a column after a specific field on existing tables
Author Kevin Morris
Paul & Hans,

Thanks for your quick response! For those who are interested the
final solution I devised for mapping MySQL's:

ALTER TABLE <table_name> ADD <new_column> <datatype> AFTER
<existing_column>

syntax to firebird SQL is

1. ALTER TABLE <table> ADD <new_column_name> <datatype>

2. SELECT rdb$field_position POS FROM rdb$relation_fields WHERE
rdb$relation_name='<table>' and rdb$field_name='<existing_column'

3. ALTER TABLE <table> ALTER <new_column> POSITION (<POS num from
above>+1)

So far my MySQL to Firebird conversion is going quite well. My only
peeve is the time to create a connection through JDBC with firebird
(about a second), versus MySQL (~0.1 seconds). With connection
pooling, however it's not a big deal.

Other than that, FB's robust feature set, (e.g., transactions, sub
selects, UDFs) makes it much superior.

Thanks all!

Kevin Morris

--- In ib-support@y..., Paul Vinkenoog <paul@v...> wrote:
> Hi Kevin,
>
> > Is there a way to specify the column position for a new column
> > added to an existing table.
>
> AFAIK, there is no way to specify the position when you add the
column
> (I wonder why), but this always works:
>
> ALTER TABLE <table> ADD <column> <datatype>
>
> followed by
>
> ALTER TABLE <table> ALTER <column> POSITION <1-based no.>
>
>
> Greetings,
> Paul Vinkenoog