final class AlterTable
    implements Statement, Relation
    uses Snapshot
Public API: explicitly declared with @visibility public.

A request to change a table, an index, a sequence, a view, a materialized view or a foreign table.

Mirrors PostgreSQL's AlterTableStmt (relation, cmds, objtype, missing_ok). The relation is resolved (PG-TABLE-TARGET-001) and is the relation fact of the statement; the actions are derived against it (PG-ALTER-TABLE-001). The statement changes no declaration. ONLY is written only for tables and foreign tables; a partition action stands alone. Source: https://www.postgresql.org/docs/17/sql-altertable.html.

Resolving the altered tabledoctest
$statement = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('ALTER TABLE IF EXISTS ONLY t ADD c int CHECK (c > a), ALTER b DROP NOT NULL');
    $statement->facts->relation($statement->statement)->table::class // => 'SqlSemantics\\Platform\\PostgreSql\\Model\\Statement\\Reference\\Table\\UndeclaredTable'

Properties§

public non-empty-list<AlterCommand> $commands
public AlterTarget $target
public RelationReference $relation
public bool $ifExists = false

Methods§

public function __construct(
    public AlterTarget $target,
    public RelationReference $relation,
    list<AlterCommand> $commands,
    public bool $ifExists = false,
)

Parameters

$targetAlterTargetThe kind of relation
$relationRelationReferenceThe relation
$commandslist<AlterCommand>The actions in order
$ifExistsboolWhether IF EXISTS is written
Calls 7
public function deriveStatement(Derivation $derivation): void

Resolves the relation and derives the actions.

Parameters

$derivationDerivation
Calls 2
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFact

Resolves the relation and answers its facts.

Parameters

$derivationDerivation
$environmentEnvironment
Calls 2
public function render(Output $out): void

Writes the statement.

Parameters

$outOutput
Calls 3

Test cases 9§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 2
Other tests reaching this symbol 7

Relations§

Instantiated in 1
Type declarations 4