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.

Emptying tablesdoctest
$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> $tables
public bool|null $restartIdentity = null
public DropBehavior|null $behavior = null

Methods§

public function __construct(
    list<RelationReference> $tables,
    public bool|null $restartIdentity = null,
    public DropBehavior|null $behavior = null,
)

Parameters

$tableslist<RelationReference>The tables
$restartIdentitybool|nullTrue for RESTART IDENTITY, false for CONTINUE IDENTITY, null when not written
$behaviorDropBehavior|nullCASCADE or RESTRICT, when written
Calls 2
public function deriveStatement(Derivation $derivation): void
public function render(Output $out): void

Writes the statement.

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 1
Type declarations 1