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

3
  • 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. Commented Nov 18, 2013 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. :) Commented Nov 18, 2013 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. Commented Nov 19, 2013 at 4:47

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.