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

A request to create a foreign table: a table whose rows a foreign server provides.

Mirrors PostgreSQL's CreateForeignTableStmt (a CreateStmt with servername and options). Like CREATE TABLE it provides a declaration (PG-TABLE-DECLARATION-001); its relation fact resolves to it. Source: https://www.postgresql.org/docs/17/sql-createforeigntable.html.

Declaring a foreign tabledoctest
$create = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("CREATE FOREIGN TABLE f (a int OPTIONS (column_name 'x') NOT NULL) SERVER s OPTIONS (table_name 'y')");
    [$create->declarations()[0]->columns[0]->nullability, $create->toString()] // => [\SqlSemantics\Platform\PostgreSql\Model\Statement\Type\Nullability::NotNull, "CREATE FOREIGN TABLE f (a INT OPTIONS (column_name 'x') NOT NULL) SERVER s OPTIONS (table_name 'y')"]

Properties§

public list<GenericOption> $options
public Name $server
public bool $ifNotExists = false

Methods§

public function __construct(
    public QualifiedName $name,
    public ListedColumns|PartitionOf $definition,
    public Name $server,
    list<GenericOption> $options = [],
    public bool $ifNotExists = false,
)

Parameters

$nameQualifiedNameThe table name
$definitionListedColumns|PartitionOfThe columns: a column list or a parent partitioned table
$serverNameThe foreign server
$optionslist<GenericOption>The options of the foreign table
$ifNotExistsboolWhether IF NOT EXISTS is written
Calls 2
public function deriveStatement(Derivation $derivation): void

Provides the declaration and derives the definition against it.

Parameters

$derivationDerivation
Calls 2
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFact

Answers the facts of the new table: its row shape and the declaration, without providing it.

Parameters

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

Writes the statement.

Parameters

$outOutput
Calls 4

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