final class ChangeColumn
    implements AlterCommand
    uses Snapshot
Public API: explicitly declared with @visibility public.

CHANGE [COLUMN] old definition or MODIFY [COLUMN] definition, each with [FIRST | AFTER column]: a request to redefine a column.

Mirrors PT_alter_table_change_column, which the server builds for both statements: MODIFY is CHANGE with the old name equal to the new one. The old name is kept when CHANGE writes it, and is absent for MODIFY, whose definition names the column. The expressions of the definition are derived in the scope of the changed table. The word COLUMN is optional and always written. Source: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html#alter-table-redefine-column.

Renaming and retyping a columndoctest
$alter = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('ALTER TABLE t CHANGE a b BIGINT FIRST');
    [$alter->statement->commands[0]->column?->column->value, $alter->toString()] // => ['a', 'ALTER TABLE t CHANGE COLUMN a b BIGINT FIRST']

Properties§

public ColumnName|null $column
public ColumnDefinition $definition
public ColumnPosition|null $position = null

Methods§

public function __construct(
    public ColumnName|null $column,
    public ColumnDefinition $definition,
    public ColumnPosition|null $position = null,
)

Parameters

$columnColumnName|nullThe column CHANGE redefines, or null for MODIFY
$definitionColumnDefinitionThe new definition with the new name
$positionColumnPosition|nullWhere the column goes, when written
public function changed(): ColumnName
public function deriveCommand(Derivation $derivation, Environment $scope): void

Derives the expressions of the definition.

Parameters

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

Writes the action.

Parameters

$outOutput
Calls 1

Test cases 1§

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

Dedicated tests 1

Relations§

Instantiated in 2
Method calls 1
Type checks 1
Type declarations 1