Skip to content

Structure

SQLAlterTable

An expression representing an ALTER TABLE query. Used to modify the structure of existing tables.
struct SQLAlterTable

Overview

This expression is partially dialect-aware and will respect specific settings under SQLAlterTableSyntax. However, it does not handle the caae where a dialect has no table alteration support at all (such as SQLite).

ALTER TABLE "name"
    RENAME TO "new_name"
ALTER TABLE "new_name"
    ADD "column1" BLOB NOT NULL,
    DROP "column2",
    ALTER "column3" SET DATA TYPE TEXT

See SQLAlterTableBuilder.

Warning

There are numerous table alteration operations possible in various dialects which are not supported by this expression.

Topics

Initializers

  • init(name:)
    Create a table alteration query for a given table, with no operations specified to start with.

Instance Properties

  • addColumns
    A list of zero or more new column definitions (add column operation).
  • addTableConstraints
    A list of zero or more new table constraints (add table constraint operation).
  • dropColumns
    A list of zero or more columns to remove (drop column operation).
  • dropTableConstraints
    A list of zero or more table constraint names to remove (drop table constraint operation).
  • modifyColumns
    A list of zero or more column alteration specifications (modify column operation).
  • name
    The name of the table to alter.
  • renameTo
    If not nil, a new name for the table (rename table operation).

Instance Methods

  • serialize(to:)
    Invoked when a request is made to serialize the expression to raw SQL.

Relationships

Conforms To

See Also

Query Expressions

  • SQLAlterEnum
    An expression representing an ALTER TYPE query. Used to add new cases to enumeration types.
  • SQLCreateEnum
    An expression representing a CREATE TYPE query. Used to create enumeration types.
  • SQLCreateIndex
    An expression representing a CREATE INDEX query. Used to add indexes over columns to an existing table.
  • SQLCreateTable
    An expression representing a CREATE TABLE query. Used to create new tables.
  • SQLCreateTrigger
    An expression representing a CREATE TRIGGER query. Used to create new triggers for actions on a table.
  • SQLDelete
    An expression representing a CREATE TRIGGER query. Used to remove rows from a table.
  • SQLDropEnum
    An expression representing a DROP TYPE query. Used to delete enumeration types.
  • SQLDropIndex
    An expression representing a DROP INDEX query. Used to delete indexes from tables.
  • SQLDropTable
    An expression representing a DROP TABLE query. Used to delete entire tables.
  • SQLDropTrigger
    An expression representing a DROP TRIGGER query. Used to delete triggers.
  • SQLInsert
    An expression representing an INSERT query. Used to add new rows to a table.
  • SQLSelect
    An expression representing a SELECT query. Used to retrieve rows and expression results from a database.
  • SQLUnion
    An expression representing two or more SELECT queries joined by UNION clauses. Used to merge the results of multiple queries into a single result set.
  • SQLUpdate
    An expression representing an UPDATE query. Used to modify existing rows in a single table.