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

A request to create a view, or to replace one with OR REPLACE.

Rule: MYSQL-CREATE-VIEW-001. The statement provides one declaration made from the output of the query (MYSQL-VIEW-FACTS-001), a view; it returns no rows. OR REPLACE refuses a name declared as a base table (MYSQL-RELATION-KIND-001). IF NOT EXISTS (MySQL 9.1 and later, part of the definition) does not change what it declares. Source: https://dev.mysql.com/doc/refman/8.4/en/create-view.html, https://dev.mysql.com/doc/refman/9.1/en/create-view.html. Status: Implemented.

Declaring a view with a column listdoctest
$view = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE OR REPLACE VIEW v (one, two) AS SELECT 1, 2');
    [$view->statement->orReplace, $view->declarations()[0]->columns[1]->name->value] // => [true, 'two']

Properties§

public ViewDefinition $definition
public bool $orReplace = false

Methods§

public function __construct(public ViewDefinition $definition, public bool $orReplace = false)

Parameters

$definitionViewDefinitionThe view definition
$orReplaceboolWhether OR REPLACE is written
public function deriveStatement(Derivation $derivation): void

Derives the query and provides the declaration of the view.

Parameters

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

Writes the statement.

Parameters

$outOutput
Calls 2

Test cases 5§

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 4

Relations§

Instantiated in 1
Type declarations 1