final class ViewDefinition
    implements Node
    uses Snapshot
Public API: explicitly declared with @visibility public.

The part a CREATE VIEW and an ALTER VIEW share: algorithm, definer, security, name, column list, query and check option.

Source: https://dev.mysql.com/doc/refman/8.4/en/create-view.html, https://dev.mysql.com/doc/refman/8.4/en/alter-view.html.

Reading a view definitiondoctest
$view = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE ALGORITHM = MERGE SQL SECURITY INVOKER VIEW v (x) AS SELECT 1 WITH LOCAL CHECK OPTION');
    [$view->statement->definition->algorithm, $view->statement->definition->security, $view->statement->definition->check] // => [\SqlSemantics\Platform\MySql\Statement\View\ViewAlgorithm::Merge, \SqlSemantics\Platform\MySql\Statement\View\ViewSecurity::Invoker, \SqlSemantics\Platform\MySql\Statement\View\ViewCheckOption::Local]

Properties§

public non-empty-list<Name>|null $columns
public Query $query
public ViewAlgorithm|null $algorithm = null
public Account|null $definer = null
public ViewSecurity|null $security = null
public ViewCheckOption|null $check = null
public bool $ifNotExists = false

Methods§

public function __construct(
    public QualifiedName $name,
    public Query $query,
    list<Name>|null $columns = null,
    public ViewAlgorithm|null $algorithm = null,
    public Account|null $definer = null,
    public ViewSecurity|null $security = null,
    public ViewCheckOption|null $check = null,
    public bool $ifNotExists = false,
)

Parameters

$nameQualifiedNameThe view name
$queryQueryThe query the view stands for
$columnslist<Name>|nullThe column list; null when none is written, otherwise at least one
$algorithmViewAlgorithm|nullThe ALGORITHM clause, when written
$definerAccount|nullThe DEFINER clause, when written
$securityViewSecurity|nullThe SQL SECURITY clause, when written
$checkViewCheckOption|nullThe WITH CHECK OPTION clause, when written
$ifNotExistsboolWhether IF NOT EXISTS is written (MySQL 9.1 and later)
Calls 3
public function render(Output $out): void

Writes the clauses after VIEW: IF NOT EXISTS, the name, the column list, the query and the check option.

Parameters

$outOutput
Calls 7

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
Method calls 2
Type declarations 4