Helpful Information
 
 
Category: Databases
Changing order of fields in a table?

Whats the easiest way to change the order of fields in a table structure?

There isn't AFAIK. But if you're doing 'SELECT * FROM table_name' and you want the
order changed, then you can 'SELECT' the column names in the order you want ie.
'SELECT second_field,first_field FROM table_name'.

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by gjs:
Whats the easiest way to change the order of fields in a table structure?[/quote]

One way is to copy the table to something else then re-create it with the columns in right order, e.g. you have a table with three columns a,b and c:

create table table_copy
select * from orig_table;

<you now have a copy of orig_table in table_copy>

Then:

drop table orig_table;

and finally:

create table new_ordered_table
select b,c,a from table_copy ;










privacy (GDPR)