Class
SQLCreateTableBuilder
Builds
SQLCreateTable queries.final class SQLCreateTableBuilder
Topics
Initializers
Instance Properties
var columns: [any SQLExpression]The set of column definitions.var createTable: SQLCreateTableSQLCreateTablequery being built.var database: any SQLDatabaseConnection to execute query on.var query: any SQLExpressionQuery being built.
Instance Methods
func check(_:named:)Add aCHECKconstraint to the table.func column(any SQLExpression) -> SelfAdd a new column definition.func column(_:type:_:)Add a new column by name, type, and constraints.func column(definitions: [SQLColumnDefinition]) -> SQLCreateTableBuilderAdd multiple column definitions.func foreignKey(_:references:_:onDelete:onUpdate:named:)Add aFOREIGN KEYconstraint to the table.func ifNotExists() -> SelfIt is usually an error to attempt to create a new table in a database that already contains a table, index or view of the same name. However, if the “IF NOT EXISTS” clause is specified as part of the CREATE TABLE statement and a table or view of the same name already exists, the CREATE TABLE command simply has no effect (and no error message is returned). An error is still returned if the table cannot be created because of an existing index, even if the “IF NOT EXISTS” clause is specified.func primaryKey(_:named:)Add aPRIMARY KEYconstraint to the table.func select((SQLSubqueryBuilder) throws -> SQLSubqueryBuilder) rethrows -> SelfSpecify aSELECTquery to be used to populate the new table.func temporary() -> SelfMark the new table as temporary.func unique(_:named:)Add aUNIQUEconstraint to the table.
Relationships
Conforms To
See Also
Query Builders
class SQLAlterEnumBuilderBuildsSQLAlterEnumqueries.class SQLAlterTableBuilderBuildsSQLAlterTablequeries.class SQLConflictUpdateBuilderA builder for specifying column updates and an optional predicate to be applied to rows that caused unique key conflicts during anINSERT.class SQLCreateEnumBuilderBuildsSQLCreateEnumqueries.class SQLCreateIndexBuilderBuildsSQLCreateIndexqueries.class SQLCreateTriggerBuilderBuildsSQLCreateTriggerqueries.class SQLDeleteBuilderBuildsSQLDeletequeries.class SQLDropEnumBuilderBuildsSQLDropEnumqueries.class SQLDropIndexBuilderBuildsSQLDropIndexqueries.class SQLDropTableBuilderBuildsSQLDropTablequeries.class SQLDropTriggerBuilderBuildsSQLDropTriggerqueries.class SQLInsertBuilderBuildsSQLInsertqueries.class SQLPredicateGroupBuilderNestedSQLPredicateBuilderfor building expression groups.class SQLRawBuilderBuilds raw SQL queries.class SQLReturningResultBuilderA builder returned from the methods ofSQLReturningBuilder; this builder wraps the original builder with one which providesSQLQueryFetcherconformance. As such, thereturning(_:)methods must always be the last ones in any call chain.