Represents a named database sequence. The :class:`.Sequence` object represents the name and configurational parameters of a database sequence. It also represents a construct that can be "executed" by a SQLAlchemy :class:`_engine.Engine` or :class:`_engine.Connection`, renderin
| 3699 | |
| 3700 | |
| 3701 | class Sequence(HasSchemaAttr, IdentityOptions, DefaultGenerator): |
| 3702 | """Represents a named database sequence. |
| 3703 | |
| 3704 | The :class:`.Sequence` object represents the name and configurational |
| 3705 | parameters of a database sequence. It also represents |
| 3706 | a construct that can be "executed" by a SQLAlchemy :class:`_engine.Engine` |
| 3707 | or :class:`_engine.Connection`, |
| 3708 | rendering the appropriate "next value" function |
| 3709 | for the target database and returning a result. |
| 3710 | |
| 3711 | The :class:`.Sequence` is typically associated with a primary key column:: |
| 3712 | |
| 3713 | some_table = Table( |
| 3714 | "some_table", |
| 3715 | metadata, |
| 3716 | Column( |
| 3717 | "id", |
| 3718 | Integer, |
| 3719 | Sequence("some_table_seq", start=1), |
| 3720 | primary_key=True, |
| 3721 | ), |
| 3722 | ) |
| 3723 | |
| 3724 | When CREATE TABLE is emitted for the above :class:`_schema.Table`, if the |
| 3725 | target platform supports sequences, a CREATE SEQUENCE statement will |
| 3726 | be emitted as well. For platforms that don't support sequences, |
| 3727 | the :class:`.Sequence` construct is ignored. |
| 3728 | |
| 3729 | .. seealso:: |
| 3730 | |
| 3731 | :ref:`defaults_sequences` |
| 3732 | |
| 3733 | :class:`.CreateSequence` |
| 3734 | |
| 3735 | :class:`.DropSequence` |
| 3736 | |
| 3737 | """ |
| 3738 | |
| 3739 | __visit_name__ = "sequence" |
| 3740 | |
| 3741 | is_sequence = True |
| 3742 | |
| 3743 | column: Optional[Column[Any]] |
| 3744 | data_type: Optional[TypeEngine[int]] |
| 3745 | |
| 3746 | def __init__( |
| 3747 | self, |
| 3748 | name: str, |
| 3749 | start: Optional[int] = None, |
| 3750 | increment: Optional[int] = None, |
| 3751 | minvalue: Optional[int] = None, |
| 3752 | maxvalue: Optional[int] = None, |
| 3753 | nominvalue: Optional[bool] = None, |
| 3754 | nomaxvalue: Optional[bool] = None, |
| 3755 | cycle: Optional[bool] = None, |
| 3756 | schema: Optional[Union[str, Literal[SchemaConst.BLANK_SCHEMA]]] = None, |
| 3757 | cache: Optional[int] = None, |
| 3758 | order: Optional[bool] = None, |
no outgoing calls