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

ALTER [COLUMN] c SET DEFAULT value, SET DEFAULT (expression) or DROP DEFAULT: a request to change the default of a column.

Mirrors PT_alter_table_set_default; no value means DROP DEFAULT. A literal default and a parenthesized expression default (8.0.13 and later) differ: the server stores the first as a constant and evaluates the second for each row, so the form is kept. The value is 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/data-type-defaults.html, https://dev.mysql.com/doc/refman/8.4/en/alter-table.html.

Setting a literal defaultdoctest
$alter = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('ALTER TABLE t ALTER a SET DEFAULT 1');
    [$alter->statement->commands[0]->expression, $alter->toString()] // => [false, 'ALTER TABLE t ALTER COLUMN a SET DEFAULT 1']

Properties§

public ColumnName $column
public Scalar|null $value
public bool $expression = false

Methods§

public function __construct(
    public ColumnName $column,
    public Scalar|null $value,
    public bool $expression = false,
)

Parameters

$columnColumnNameThe column
$valueScalar|nullThe new default, or null for DROP DEFAULT
$expressionboolWhether the default is an expression in parentheses rather than a literal
Calls 1
public function deriveCommand(Derivation $derivation, Environment $scope): void

Derives the default value.

Parameters

$derivationDerivation
$scopeEnvironment
Calls 1
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 3
Type checks 1