final class TableDeclaration
Restricted visibility: declared "@visibility SqlSemantics\Platform\MySql". Code outside that scope must not name this declaration.

Derives the declaration a table or view definition provides.

Rule: MYSQL-TABLE-DECLARATION-001. A CREATE TABLE declares one column per column definition, in order, with the type as written and the NULL fact of MYSQL-COLUMN-FLAGS-001; a column a table-level PRIMARY KEY names is NOT NULL. A generated column (VIRTUAL or STORED) is an ordinary column for reading and is declared generated: the server computes its value and accepts only DEFAULT for it in a write. An INVISIBLE column is found by name but not by * ("not part of SELECT *"): it is an implicit column of the declaration.

CREATE TABLE ... SELECT: "columns named only in the CREATE TABLE part come

  • first. Columns named in both parts or only in the SELECT part come after
  • that. The data type of SELECT columns can be overridden by also specifying
  • the column in the CREATE TABLE part." A column named in both parts takes

its name from the SELECT part and the rest from the CREATE TABLE part. A column of the SELECT part takes the name, the type and the NULL fact of its output field and is not generated, also when the field reads a generated column; the column list stops, and the declaration is incomplete, at the first field that has no determined name or type or that an unexpanded star leaves open.

CREATE VIEW: a view (RelationKind::View) with one column per output field, named by the column list when one is written, with the type and NULL fact of the field, never generated; incomplete under the same conditions and when the column list has another length. Every other declaration is a base table.

CREATE TABLE ... LIKE: the columns of the source table, as new declarations with the same names, types, NULL facts and generation (the copy keeps the generation expressions); an undeclared source leaves the declaration empty and incomplete. Terminates: one pass over the elements and the fields. Source: https://dev.mysql.com/doc/refman/8.4/en/create-table.html, https://dev.mysql.com/doc/refman/8.4/en/create-table-select.html, https://dev.mysql.com/doc/refman/8.4/en/create-table-like.html, https://dev.mysql.com/doc/refman/8.4/en/create-view.html, https://dev.mysql.com/doc/refman/8.4/en/invisible-columns.html. Status: Implemented.

Methods§

public function table(
    CreateTable $definition,
    ?QueryFact $output,
    Derivation $derivation,
): Table
public function split(
    QualifiedName $name,
    list<array{ColumnDefinition|null, Column}> $columns,
    LanguageProfile $profile,
    bool $complete,
): Table

Builds a declaration from columns, keeping INVISIBLE columns as implicit columns.

Parameters

$nameQualifiedName
$columnslist<array{ColumnDefinition|null, Column}>Each column with the definition it comes from, if any
$profileLanguageProfile
$completebool

Returns

Test cases 1
Called from 1
Calls 4
public function view(
    QualifiedName $name,
    QueryFact $output,
    list<Name|null> $names,
    bool $listed,
    LanguageProfile $profile,
): Table

Builds the declaration of a view from the output of its query and the names of its columns.

Parameters

$nameQualifiedName
$outputQueryFact
$nameslist<Name|null>The name of each column: the column list when one is written, else the names the query gives
$listedboolWhether the names are a written column list, whose length must match the query
$profileLanguageProfile

Returns

Called from 1
Calls 5
public function like(QualifiedName $name, ?Table $source, LanguageProfile $profile): Table

Builds the declaration of CREATE TABLE ... LIKE from the declaration of the source table, when it is declared.

Parameters

Returns

Test cases 1
Called from 1
Calls 3
public function renamed(Column $column, Name $name): Column

Answers a defined column under the name a field of the SELECT part gives it.

Parameters

$columnColumn
$nameName

Returns

Called from 1
Calls 1
public function find(
    Name $name,
    list<array{ColumnDefinition, Column}> $defined,
    Comparison $comparison,
): ?int

Test cases 8§

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

Dedicated tests 8

Relations§

Instantiated in 8
Method calls 10