Represent a CREATE TABLE statement.
| 539 | |
| 540 | |
| 541 | class CreateTable(TableCreateDDL): |
| 542 | """Represent a CREATE TABLE statement.""" |
| 543 | |
| 544 | __visit_name__ = "create_table" |
| 545 | |
| 546 | def __init__( |
| 547 | self, |
| 548 | element: Table, |
| 549 | include_foreign_key_constraints: Optional[ |
| 550 | typing_Sequence[ForeignKeyConstraint] |
| 551 | ] = None, |
| 552 | if_not_exists: bool = False, |
| 553 | ) -> None: |
| 554 | """Create a :class:`.CreateTable` construct. |
| 555 | |
| 556 | :param element: a :class:`_schema.Table` that's the subject |
| 557 | of the CREATE |
| 558 | :param on: See the description for 'on' in :class:`.DDL`. |
| 559 | :param include_foreign_key_constraints: optional sequence of |
| 560 | :class:`_schema.ForeignKeyConstraint` objects that will be included |
| 561 | inline within the CREATE construct; if omitted, all foreign key |
| 562 | constraints that do not specify use_alter=True are included. |
| 563 | |
| 564 | :param if_not_exists: if True, an IF NOT EXISTS operator will be |
| 565 | applied to the construct. |
| 566 | |
| 567 | .. versionadded:: 1.4.0b2 |
| 568 | |
| 569 | """ |
| 570 | super().__init__(element, if_not_exists=if_not_exists) |
| 571 | self.columns = [CreateColumn(column) for column in element.columns] |
| 572 | self.include_foreign_key_constraints = include_foreign_key_constraints |
| 573 | |
| 574 | def to_metadata(self, metadata: MetaData, table: Table) -> Self: |
| 575 | return self.__class__(table, if_not_exists=self.if_not_exists) |
| 576 | |
| 577 | |
| 578 | class _TableViaSelect(TableCreateDDL, ExecutableDDLElement): |
no outgoing calls