I am trying to move a field from the end of my table to somewhere in the middle. How do I do this?
I used to be able to do this after clicking Edit on the table’s context menu. Then I would cut and paste the field I wanted to move to first place. And then the one I wanted in second place. And so forth. Then I’d save the table. Exit the edit window. And save the file.
Now when I do that, the changes do not take effect.
I have no idea why. It’s weird and it’s frustrating.
(And, no, I haven’t changed any settings or upgraded the software. I’m using LO 22.214.171.124 on Win7.)
SQL. I don’t know of a way to do this within Base easily. I typically use SQL Workbench or MySQL Workbench depending on what database I’m using. If the DB is empty, it is fairly simple. Take the SQL source displayed, re-arrange (cut & paste) what you want, Drop the old & create the new. If, however, you have data in the DB, it can be tedious. Create a new table with what you want then with SQL, copy the data from one table to another field by field. As a side note, there is no logical reason that fields have any sequence within a database.
Confirmed on LO 126.96.36.199, you can try to drag-drop the columns but the cursor changed to the
You can't do this one, and doesn’t matter how you drag or drop. However, I checked the HSQLDB 1.8.0 syntax and it confirms you can change the order through SQL:
http://www.hsqldb.org/doc/guide/ch09.html#alter_table-section. Although I can understand the reason for lack of such feature to be harder to figure out which column was moved where, it’s not impossible, just keep copies of the column names.
I also want to note that it is as easy as drag & drop to move columns using MySQL Workbench.
I came across this (old) question trying to do the same thing. Not as professional but I found a work around that I found easier than using SQL. (Although I guess I should look at MySQL Workbench…)
Probably easier/safer If you haven’t got lots of data in your table and I would make sure I had a backup first and know the ‘field type’ /settings of each field.
I ‘imported’ (dragged the table into) a blank calc sheet. Added a new column and the new field name I wanted.
Deleted the table in Base, went back to Calc and exported (dragged back) the table to Base. Gave it the same name, used the column headings as field names etc. I did have to go through and reset the field type of each field.
I might have to edit a couple of queries and a form… but quicker than having to make a new table, typing in 15 field names etc.
I guess I should say that I had no data in the table - I was using a copy of a pre-existing database as a template and needed to add and change a couple of field names in one table. And also I import and export tables between Base and Calc quite often - I get data sent to me as an Excel file (don’t have a choice about it) that I want to add to a database.
Even easier. Drag the database table into a blank calc sheet, move columns as required and save as original file name. Open Base with the database table and the columns have been changed. Do backup first though.