Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

H2 database: is it possible to rename a constraint?

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.

like image 546
Reto Höhener Avatar asked Jul 07 '13 07:07

Reto Höhener


People also ask

Can you rename a constraint?

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.

How do you rename a constraint in SQL?

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.

How do I change the column name in an H2 database?

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.


1 Answers

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)

like image 72
Wild Pottok Avatar answered Oct 30 '22 03:10

Wild Pottok