classCreateView
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.
$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 $definitionpublic bool $orReplace = falseMethods§
public function __construct(public ViewDefinition $definition, public bool $orReplace = false)Parameters
$definition | ViewDefinition | The view definition |
$orReplace | bool | Whether OR REPLACE is written |
public function deriveStatement(Derivation $derivation): voidDerives the query and provides the declaration of the view.
Parameters
$derivation | Derivation |
Calls 8
- method-call RelationKinds::require() line 51
- new RelationKinds line 51
- method-call Derivation::table() line 51
- method-call Derivation::environment() line 51
- class-const RelationKind::View() line 51
- method-call Derivation::declare() line 53
- method-call ViewFacts::derive() line 53
- new ViewFacts line 53
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 2
- method-call Output::keyword() line 61
- method-call ViewDefinition::renderHead() line 65
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
CreateViewTestcalls