A table-level FOREIGN KEY constraint. Defines a single column or composite FOREIGN KEY ... REFERENCES constraint. For a no-frills, single column foreign key, adding a :class:`_schema.ForeignKey` to the definition of a :class:`_schema.Column` is a shorthand equivalent for an unna
| 4584 | |
| 4585 | |
| 4586 | class ForeignKeyConstraint(ColumnCollectionConstraint): |
| 4587 | """A table-level FOREIGN KEY constraint. |
| 4588 | |
| 4589 | Defines a single column or composite FOREIGN KEY ... REFERENCES |
| 4590 | constraint. For a no-frills, single column foreign key, adding a |
| 4591 | :class:`_schema.ForeignKey` to the definition of a :class:`_schema.Column` |
| 4592 | is a |
| 4593 | shorthand equivalent for an unnamed, single column |
| 4594 | :class:`_schema.ForeignKeyConstraint`. |
| 4595 | |
| 4596 | Examples of foreign key configuration are in :ref:`metadata_foreignkeys`. |
| 4597 | |
| 4598 | """ |
| 4599 | |
| 4600 | __visit_name__ = "foreign_key_constraint" |
| 4601 | |
| 4602 | def __init__( |
| 4603 | self, |
| 4604 | columns: _typing_Sequence[_DDLColumnArgument], |
| 4605 | refcolumns: _typing_Sequence[_DDLColumnArgument], |
| 4606 | name: _ConstraintNameArgument = None, |
| 4607 | onupdate: Optional[str] = None, |
| 4608 | ondelete: Optional[str] = None, |
| 4609 | deferrable: Optional[bool] = None, |
| 4610 | initially: Optional[str] = None, |
| 4611 | use_alter: bool = False, |
| 4612 | link_to_name: bool = False, |
| 4613 | match: Optional[str] = None, |
| 4614 | table: Optional[Table] = None, |
| 4615 | info: Optional[_InfoType] = None, |
| 4616 | comment: Optional[str] = None, |
| 4617 | **dialect_kw: Any, |
| 4618 | ) -> None: |
| 4619 | r"""Construct a composite-capable FOREIGN KEY. |
| 4620 | |
| 4621 | :param columns: A sequence of local column names. The named columns |
| 4622 | must be defined and present in the parent Table. The names should |
| 4623 | match the ``key`` given to each column (defaults to the name) unless |
| 4624 | ``link_to_name`` is True. |
| 4625 | |
| 4626 | :param refcolumns: A sequence of foreign column names or Column |
| 4627 | objects. The columns must all be located within the same Table. |
| 4628 | |
| 4629 | :param name: Optional, the in-database name of the key. |
| 4630 | |
| 4631 | :param onupdate: Optional string. If set, emit ON UPDATE <value> when |
| 4632 | issuing DDL for this constraint. Typical values include CASCADE, |
| 4633 | DELETE and RESTRICT. |
| 4634 | |
| 4635 | .. seealso:: |
| 4636 | |
| 4637 | :ref:`on_update_on_delete` |
| 4638 | |
| 4639 | :param ondelete: Optional string. If set, emit ON DELETE <value> when |
| 4640 | issuing DDL for this constraint. Typical values include CASCADE, |
| 4641 | SET NULL and RESTRICT. Some dialects may allow for additional |
| 4642 | syntaxes. |
| 4643 |
no outgoing calls