classCreateDatabase
final class CreateDatabase
implements Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] name [option …]: a request to create a database.
Mirrors SQLCOM_CREATE_DB with HA_CREATE_INFO. Rule: MYSQL-CREATE-DATABASE-001. The options are kept in written order. A database holds no columns, so the statement declares no relation. SCHEMA is a synonym of DATABASE, which the lexer folds. Source: https://dev.mysql.com/doc/refman/8.4/en/create-database.html. Status: Implemented.
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('create schema if not exists shop default charset utf8mb4 collate utf8mb4_bin');
[$create->toString(), count($create->statement->options)] // => ['CREATE DATABASE IF NOT EXISTS shop CHARACTER SET utf8mb4 COLLATE utf8mb4_bin', 2]Properties§
public list<DatabaseOption> $optionspublic bool $ifNotExistspublic Name $nameMethods§
public function __construct(
public bool $ifNotExists,
public Name $name,
list<DatabaseOption> $options = [],
)Parameters
$ifNotExists | bool | Whether IF NOT EXISTS is written |
$name | Name | The database name |
$options | list<DatabaseOption> | The options in written order |
Throws
InvalidConstruction When an option is READ ONLY, which only ALTER DATABASE takesCalls 3
- static-call Check::listOf() line 48
- class-const DatabaseOption::class() line 48
- static-call Check::input() line 50
public function deriveStatement(Derivation $derivation): voidHas nothing to derive: a database is no relation.
Parameters
$derivation | Derivation |
public function render(Output $out): voidWrites the request.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 66
- method-call Output::name() line 70
- class-const NameUse::Qualifier() line 70
- method-call Output::node() line 72
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
CreateDatabaseTestcalls