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

A request to create a table from the rows of a prepared statement: CREATE TABLE ... AS EXECUTE.

Mirrors PostgreSQL's CreateTableAsStmt whose query is an ExecuteStmt. The columns are those of the prepared statement, which a context does not declare: the statement provides a declaration of the table with its system columns and no known column (PG-QUERY-TABLE-001). Source: https://www.postgresql.org/docs/17/sql-createtableas.html.

Declaring the table of a prepared statementdoctest
$create = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE TABLE t AS EXECUTE q (1) WITH DATA');
    [$create->declarations()[0]->complete, $create->toString()] // => [false, 'CREATE TABLE t AS EXECUTE q (1) WITH DATA']

Properties§

public CreateTarget $target
public Statement $execute
public Persistence $persistence = Persistence::Permanent
public bool $ifNotExists = false
public bool|null $withData = null

Methods§

public function __construct(
    public CreateTarget $target,
    public Statement $execute,
    public Persistence $persistence = Persistence::Permanent,
    public bool $ifNotExists = false,
    public bool|null $withData = null,
)

Parameters

$targetCreateTargetThe new table
$executeStatementThe EXECUTE statement
$persistencePersistenceThe persistence
$ifNotExistsboolWhether IF NOT EXISTS is written
$withDatabool|nullTrue for WITH DATA, false for WITH NO DATA, null when not written
Calls 1
public function deriveStatement(Derivation $derivation): void

Derives the EXECUTE statement and provides the declaration of the table.

Parameters

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

Writes the statement.

Parameters

$outOutput
Calls 4

Test cases 2§

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 1

Relations§

Instantiated in 1
Type declarations 1