I have a database with many duplicate index, foreign key, and primary key names. Duplicate index names can be renamed using:
ALTER INDEX <index name> ON <creator>.<tablename> RENAME TO <new name>
So that's fixed.
But keys are not indexes, so it doesn't work on keys:
"Cannot find index named '<index name>'"
There is a constraint rename syntax:
ALTER TABLE <creator>.<tablename> RENAME CONSTRAINT <constraint name> TO <new name>
This doesn't work on keys either:
"Constraint '<constraint name>' not found"
Is there any way to rename a foreign or primary key in SQLAnywhere without dropping and recreating the key?
Best Answer
You don't say which version of SQL Anywhere you are using, but in 16 I think you can use ALTER INDEX to do what you want. From the help:
Note what it says about using the ALTER TABLE statement to rename the constraint name if needed. If you need more help try the dedicated SQL Anywhere forum at http://sqlanywhere-forum.sap.com/