Is there a way to rename a constraint in H2 database?
Same question as this one: SQL Server rename a constraint?, but for H2 database.
It is not possible to rename a constraint for a column referenced by a view. For more details, see View Dependencies. Tip: This command can be combined with other ALTER TABLE commands in a single statement.
sp_rename automatically renames the associated index whenever a PRIMARY KEY or UNIQUE constraint is renamed. If a renamed index is tied to a PRIMARY KEY constraint, the PRIMARY KEY constraint is also automatically renamed by sp_rename . sp_rename can be used to rename primary and secondary XML indexes.
Alter Table Alter Column. This command is used to change the structure and properties of the column of a particular table. Changing the properties means changing the datatype of a column, rename a column, change the identity value, or change the selectivity.
Mr Thomas Muellers's answer was correct at the time, but H2 has improved, since. It now allows renaming a constraint:
ALTER TABLE RENAME CONSTRAINT
(since version 1.4.192)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With