ALTER TABLE ALTER COLUMN RENAME Syntax
Hi everyone, i cant understand what is wrong in my query:
ALTER TABLE MyNamespace.MyTable ALTER COLUMN CurrentColumnName RENAME NewColumnName
I just want to rename column name using sql.
I could not find any life example using this syntax.
SQLCODE for this query is -25:
-25 Input encountered after end of query
Quote from documentation:
- Rename the column using the syntax ALTER TABLE tablename ALTER COLUMN oldname RENAME newname. Renaming a column changes the SQL field name. It does not change the corresponding persistent class property name. ALTER COLUMN oldname RENAME newname replaces oldfield name references in trigger code and ComputeCode.'
Can't reproduce. Can you post an example please?
Maybe you have a semicolon after your query?
Example:
I have table named fixxer.decars, i want to rename column "color" to "color2"
I tried to use the query above and met the error
You should contact the WRC.
Given (IRIS 2021.2):
Now:
PS: by the way Studio highlights the error in the following code
&sql(alter table fixxer.decars alter column color rename color2)
But the compilation goes without errors.
My IRIS version is 2020.1.
I will be grateful if you see any significant differences between my example and yours that cause this error. My Persistent class (this class created using 'CREATE TABLE'):
After calling
alter table fixxer.decars alter column color rename color2
it became
It looks like something was fixed in 2021.2.
I think so too. I also noticed that in IRIS 2020.1 documentation is nothing about 'ALTER COLUMN RENAME' syntax. May be there is another way to rename column name using SQL but i cant find it. Thanks for response.
Yes, check alter-column-action ::=
2020.1
2021.1
This is indeed a new piece of ALTER TABLE syntax we introduced between 2020.1 and 2021.1, so nothing wrong with your 2020.1 instance
So, the author is not lucky and in its version this feature is not available.
It seems you have the wrong addressee, I have 2021.2 :)
I won't be able to check for version 2020.1 since I have 2021.2.
Try to make a DROP COLUMN and then ADD COLUMN (of course according to the documentation for your version)
Yes, I decided to use that approach. Thank you