When executing the code
ALTER TABLE tablename RENAME COLUMN oldname TO newname;
I get the error:
Execution error: Incorrect syntax near 'RENAME'
what is my mistake? The error appears whether i use quotes or not
Hi Johannes,
This should be the correct Vertica statement, especially when double quotes are applied to the table and column names. No clue on this one, sorry!
Hi Jan-peter,
thanks for the response. I also cannot use CHANGE e.g. - it always ends in the execution error for an incorrect syntax.
Do you have any other idea how to solve the renaming? Or do you have any idea regarding the root of the problem, when the statement should be correct? maybe something in the settings?
Best, Johannes
Hi Johannes,
The same has been working for me would request you to check a few things
- Do not use quotes for the OLD_NAME or NEW_NAME
- Avoid space in the OLD_NAME or NEW_NAME
ALTER TABLE TABLENAME RENAME COLUMN OLD_NAME TO NEW_NAME
PS: A screenshot of the original query in case you are able to share will give a better idea of the problem
Silly question, but ... Is Tablename a Table or a View?
Hey,
thanks for your replies. See the screenshot above.
It is a table.
Hey,
thanks for your replies. See the screenshot above.
It is a table.
Yep, I check and if you try to rename a column from a view you get a different error.
FYI this worked in my environment
ALTER TABLE "CV_PRESUPUESTOS" RENAME COLUMN "NUM_PRESUPUESTO" TO "NEW_PRESUPUESTO"
HTH
Hey,
thanks for your replies. See the screenshot above.
It is a table.
Strange, if I reproduce your SQL snippet the 'RENAME' keyword is marked blue. It seems it is not recognized in your case. Do you have special characters around it somehow? Otherwise it might be a technical difference/bug related to your realm/environment.
You're right, in a different environment the RENAME is marked blue for me as well.
Strange.
Hey,
thanks for your replies. See the screenshot above.
It is a table.
Agree with Jan-peter van der Steege. can you try removing the space otherwise this looks more like a bug related to your environment. Would suggest to raise a support ticket
Use this command (replace <> with your values):
EXEC sp_rename 'dbo.<tablename>.<columnoldname>', '<columnnewname>', 'COLUMN';
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.