classTruncateTable
final class TruncateTable
implements Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.A request to empty tables.
Mirrors PostgreSQL's TruncateStmt (relations, restart_seqs, behavior). Each table is resolved (PG- TABLE-TARGET-001) and is the relation fact of its reference; a view, a materialized view or a sequence is not a table (truncate_check_rel; PG-RELATION-KIND-001), and a foreign table depends on its wrapper. The optional TABLE word is not kept; CONTINUE IDENTITY is the default and is kept when written. Source: https://www.postgresql.org/docs/17/sql-truncate.html.
$statement = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('TRUNCATE TABLE ONLY a, b RESTART IDENTITY CASCADE');
[count($statement->statement->tables), $statement->toString()] // => [2, 'TRUNCATE ONLY a, b RESTART IDENTITY CASCADE']Properties§
public non-empty-list<RelationReference> $tablespublic bool|null $restartIdentity = nullpublic DropBehavior|null $behavior = nullMethods§
public function __construct(
list<RelationReference> $tables,
public bool|null $restartIdentity = null,
public DropBehavior|null $behavior = null,
)Parameters
$tables | list<RelationReference> | The tables |
$restartIdentity | bool|null | True for RESTART IDENTITY, false for CONTINUE IDENTITY, null when not written |
$behavior | DropBehavior|null | CASCADE or RESTRICT, when written |
Calls 2
- static-call Check::listOf() line 52
- class-const RelationReference::class() line 52
public function deriveStatement(Derivation $derivation): voidResolves each table.
Parameters
$derivation | Derivation |
Calls 9
- new RelationKinds line 60
- method-call RelationKinds::of() line 62
- method-call Derivation::target() line 62
- method-call Targets::resolve() line 62
- new Targets line 62
- method-call RelationKinds::require() line 63
- class-const RelationKind::BaseTable() line 63
- class-const RelationKind::ForeignTable() line 63
- class-const KindRule::NotTable() line 63
public function render(Output $out): voidTest cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.