3

I need to change specific column's position I tried Ted Hopp's solution in Move Column in MYSQL

ALTER TABLE EMPLOYEES MODIFY COLUMN fname VARCHAR(25) AFTER password

and i got this error:

Error code -1, SQL state 42X01: Syntax error: Encountered "MODIFY" at line 1, column 22.

So any idea how to do it with Derby

Community
  • 1
  • 1
user2954718
  • 67
  • 1
  • 8
  • 2
    Why do you need to move the column? You can always re-arrange the columns in the order you prefer in your SELECT statement, or in your program after you retrieve the data. – Bryan Pendleton Nov 18 '13 at 14:51
  • i have a db and i did some changes, so i wanted to sort columns because i knew it is possible in mysql. and i was wondering if derby have the same feature or not. :) – user2954718 Nov 18 '13 at 14:59
  • 1
    If it's really important to you, you could: (a) create a new table, with the columns in the order you want, (b) insert into newtable select column-list from oldtable (c) drop table oldtable, (d) rename table newtable to oldtable. – Bryan Pendleton Nov 19 '13 at 04:47

1 Answers1

4

Derby uses ADD COLUMN (docs):

ALTER TABLE EMPLOYEES ADD COLUMN fname VARCHAR(25)

There is no way to insert columns before or after a certain column; they are always appended.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820