classDropTable
final class DropTable
implements Statement
uses Snapshot
@visibility public.DROP [TEMPORARY] TABLE [IF EXISTS] t, … [RESTRICT | CASCADE]: a request to remove tables.
Mirrors PT_drop_table_stmt. Rule: MYSQL-DROP-TABLE-001. Each table name resolves by MYSQL-CHANGE-TARGET-001 and its resolution is the relation fact of its TargetTable; under IF EXISTS a name a complete context does not declare resolves to AbsentTable. A table named twice is the diagnostic RepeatedTable. A declared view is not a table DROP TABLE finds: without IF EXISTS it is refused (MYSQL-RELATION-KIND-001). TEMPORARY restricts the request to temporary tables, which a declaration context does not distinguish. RESTRICT and CASCADE have no effect and are kept as written. The statement removes no declaration and provides none. TABLE and TABLES are synonyms. Source: https://dev.mysql.com/doc/refman/8.4/en/drop-table.html. Status: Implemented.
$semantics = new \SqlSemantics\Platform\MySql\Semantics();
$drop = $semantics->analyze('drop tables if exists t, u cascade', []);
[$drop->toString(), $drop->statement->behavior] // => ['DROP TABLE IF EXISTS t, u CASCADE', \SqlSemantics\Platform\MySql\Statement\Alter\DropBehavior::Cascade]Properties§
public list<TargetTable> $tablespublic bool $temporarypublic bool $ifExistspublic DropBehavior|null $behavior = nullMethods§
public function __construct(
public bool $temporary,
public bool $ifExists,
list<TargetTable> $tables,
public DropBehavior|null $behavior = null,
)Parameters
$temporary | bool | Whether TEMPORARY is written |
$ifExists | bool | Whether IF EXISTS is written |
$tables | list<TargetTable> | The tables in order; at least one |
$behavior | DropBehavior|null | RESTRICT or CASCADE, when written |
Calls 3
- static-call Check::input() line 55
- static-call Check::listOf() line 56
- class-const TargetTable::class() line 56
public function deriveStatement(Derivation $derivation): voidRecords the resolution of each table and reports a table named twice.
Parameters
$derivation | Derivation |
Calls 10
- new Targets line 64
- method-call Derivation::target() line 66
- method-call Targets::optional() line 66
- method-call RelationKinds::refuseView() line 68
- new RelationKinds line 68
- class-const KindRefusal::UnknownTable() line 68
- function-call
array_sliceline 70 - method-call Targets::same() line 71
- method-call Derivation::report() line 72
- new RepeatedTable line 72
public function render(Output $out): voidWrites the request.
Parameters
$out | Output |
Calls 2
- method-call Output::keyword() line 84
- method-call Output::list() line 92
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.