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

RENAME TABLE old TO new, …: a request to rename tables, one rename after the other.

Mirrors PT_rename_table_stmt (LEX of 5.x). Rule: MYSQL-RENAME-TABLE-001. The renames run left to right, so a later rename sees the names the earlier ones produced (RENAME TABLE a TO tmp, b TO a, tmp TO b swaps two tables). The relation fact of each TableRenaming is the resolution of its old name at that time (MYSQL-RENAMINGS-001): a name an earlier rename produced resolves to that table, a name an earlier rename moved away is missing. A new name that exists at that time is the diagnostic TableExists. The statement changes no declaration and provides none. TABLE and TABLES are synonyms. Source: https://dev.mysql.com/doc/refman/8.4/en/rename-table.html. Status: Implemented.

Swapping two tables through a third namedoctest
$rename = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('RENAME TABLES a TO tmp, b TO a, tmp TO b');
    [count($rename->statement->renamings), $rename->toString()] // => [3, 'RENAME TABLE a TO tmp, b TO a, tmp TO b']

Properties§

public list<TableRenaming> $renamings

Methods§

public function __construct(list<TableRenaming> $renamings)

Parameters

$renamingslist<TableRenaming>The renames in order; at least one
Calls 3
public function deriveStatement(Derivation $derivation): void

Records the resolution of each old name in order and reports new names that already exist.

Parameters

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

Writes the request.

Parameters

$outOutput
Calls 1

Test cases 3§

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

Dedicated tests 1
Other tests reaching this symbol 2

Relations§

Instantiated in 1
Type declarations 1