Search code examples
sqlliquibase

Default value of ondelete attibute of addForeignKeyConstraint liquibase


According to this documentation:

http://www.liquibase.org/documentation/changes/add_foreign_key_constraint.html

liquibase allows to create foreign keys. There is an interesting attribute there called onDelete. It is written that possible values are: 'CASCADE', 'SET NULL', 'SET DEFAULT', 'RESTRICT', 'NO ACTION', but it is not explicitly mentioned which one is default one.

Any ideas? Or is it better just to mention it explicitly?

I guess that it can depend on the database as well. I use PostgreSQL, MySQL and MsSQL.


Solution

  • If you do not specify a value, Liquibase will not include any additional clauses in the SQL so it actually depends on your database default.

    The default behavior is normally RESTRICT.