Change column / field order in OpenOffice Base ( HSQL )

By | January 23, 2009

Altering the sequence of fields of a table was a feature I was looking for in OpenOffice Base. It is not directly possible to drag the columns or fields and alter their sequence.

A SQL workaround can do the same thing.

If the sequence of fields is :

name , email , address , phone

and phone is to be brought before address like this :

name , email , phone , address

then the sql for this should be

1. ALTER TABLE "tablename" ADD COLUMN "phone2" INTEGER BEFORE "address"

2. UPDATE "tablename" SET "phone2" = "phone"

3. ALTER TABLE "tablename" DROP COLUMN "phone"

4. ALTER TABLE "tablename" ALTER COLUMN "phone2" RENAME TO "phone"

Then View > Refresh Tables in the top menu. And open the table again for viewing.
The sequence should now be name , email , phone , address

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

Leave a Reply

Your email address will not be published. Required fields are marked *