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
| 4964 | |
| 4965 | |
| 4966 | class ForeignKeyConstraint(ColumnCollectionConstraint): |
| 4967 | """A table-level FOREIGN KEY constraint. |
| 4968 | |
| 4969 | Defines a single column or composite FOREIGN KEY ... REFERENCES |
| 4970 | constraint. For a no-frills, single column foreign key, adding a |
| 4971 | :class:`_schema.ForeignKey` to the definition of a :class:`_schema.Column` |
| 4972 | is a |
| 4973 | shorthand equivalent for an unnamed, single column |
| 4974 | :class:`_schema.ForeignKeyConstraint`. |
| 4975 | |
| 4976 | Examples of foreign key configuration are in :ref:`metadata_foreignkeys`. |
| 4977 | |
| 4978 | """ |
| 4979 | |
| 4980 | __visit_name__ = "foreign_key_constraint" |
| 4981 | |
| 4982 | def __init__( |
| 4983 | self, |
| 4984 | columns: _typing_Sequence[_DDLColumnArgument], |
| 4985 | refcolumns: _typing_Sequence[_DDLColumnReferenceArgument], |
| 4986 | name: _ConstraintNameArgument = None, |
| 4987 | onupdate: Optional[str] = None, |
| 4988 | ondelete: Optional[str] = None, |
| 4989 | deferrable: Optional[bool] = None, |
| 4990 | initially: Optional[str] = None, |
| 4991 | use_alter: bool = False, |
| 4992 | link_to_name: bool = False, |
| 4993 | match: Optional[str] = None, |
| 4994 | table: Optional[Table] = None, |
| 4995 | info: Optional[_InfoType] = None, |
| 4996 | comment: Optional[str] = None, |
| 4997 | **dialect_kw: Any, |
| 4998 | ) -> None: |
| 4999 | r"""Construct a composite-capable FOREIGN KEY. |
| 5000 | |
| 5001 | :param columns: A sequence of local column names. The named columns |
| 5002 | must be defined and present in the parent Table. The names should |
| 5003 | match the ``key`` given to each column (defaults to the name) unless |
| 5004 | ``link_to_name`` is True. |
| 5005 | |
| 5006 | :param refcolumns: A sequence of foreign column names or Column |
| 5007 | objects. The columns must all be located within the same Table. |
| 5008 | |
| 5009 | :param name: Optional, the in-database name of the key. |
| 5010 | |
| 5011 | :param onupdate: Optional string. If set, emit ON UPDATE <value> when |
| 5012 | issuing DDL for this constraint. Typical values include CASCADE, |
| 5013 | DELETE and RESTRICT. |
| 5014 | |
| 5015 | .. seealso:: |
| 5016 | |
| 5017 | :ref:`on_update_on_delete` |
| 5018 | |
| 5019 | :param ondelete: Optional string. If set, emit ON DELETE <value> when |
| 5020 | issuing DDL for this constraint. Typical values include CASCADE, |
| 5021 | SET NULL and RESTRICT. Some dialects may allow for additional |
| 5022 | syntaxes. |
| 5023 |
no outgoing calls