0

Why "AFTER" not support in ucannacess ALTER TABLE?

I want to add column in position to exist column table; using database .accdb

sql = "ALTER TABLE tableName ADD COLUMN newColumnName VARCHAR(50) AFTER columnNameExist";

Example

sql = "ALTER TABLE car ADD COLUMN information VARCHAR(50) AFTER name ";

Exception

net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.0.4 java.sql.SQLSyntaxErrorException: unexpected token : AFTER

Rona Idea
  • 6,734
  • 2
  • 9
  • 12
  • @Shashanth thanks for editing the question better. Until now I haven't found the answer to the problem above – Rona Idea Dec 19 '19 at 08:11
  • I don't use the MS-Access database in my projects. I use RDBMS like MySQL. I went through the official doc for MS-Access [ALTER](https://learn.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/alter-table-statement-microsoft-access-sql#syntax) command. But, I didn't find any keyword `AFTER` which we can use with `ALTER` command. So, I don't think MS-Access supports `AFTER` command. Hence, the error is valid in your case. – Shashanth Dec 19 '19 at 08:29
  • @ScaryWombat sir this question is not related to MySQL instead it's related to MS-Access. You marked it with the wrong dupe target. – Shashanth Dec 19 '19 at 08:37
  • 1
    @Shashanth Thank you for bringing this to my attention. I had to scour really hard to find that this was related to ms-access. Maybe a tag would have been better. – Scary Wombat Dec 19 '19 at 23:55
  • @ScaryWombat I think this has to do with mysql, because the syntax used is the same :) – Rona Idea Dec 20 '19 at 02:15

1 Answers1

0

Do not use ADD COLUMN instead of this use only "ADD" in place of "ADD COLUMN" Example : ALTER TABLE members ADD date_of_registration date NULL AFTER date_of_birth; Hope this works.