DB2 by default does NOT enable foreign key constraints #45
Open
Description
DB2 by default does not enable ('enforce') foreign key checks.
Tables will be created with the NOT ENFORCED
option.
According to https://www.ibm.com/docs/en/db2/10.5?topic=constraints-creating-modifying, after the table has been created it needs to be modified using an 'ALTER TABLE` SQL operation.
In order to do the ALTER, we need the name of the constraint.
That requires either:
- Explicitly specify a unique name in a ForeignKey constraint, or
- Enable automated naming
sqlalchemy.MetaData(schema=schema, naming_convention=CONVENTION)
See also:
- https://docs.sqlalchemy.org/en/14/core/constraints.html
- https://docs.sqlalchemy.org/en/14/core/constraints.html#creating-dropping-foreign-key-constraints-via-alter
- https://www.ibm.com/docs/en/db2/10.5?topic=constraints-creating-modifying
- https://stackoverflow.com/questions/54513136/when-we-should-use-not-enforced-with-foreign-key-constraint-in-db2
Metadata
Assignees
Labels
No labels