QueryInterface.createView() method
Creates a view from a complete SQL definition.
Signature:
createView(viewName: string, viewDefinition: string): Promise<any>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
viewName |
string |
The name the definition is expected to declare. |
|
viewDefinition |
string |
The complete create statement. |
Returns:
Promise<any>
The result of executing the definition.
Exceptions
TypeError when the definition does not declare viewName.
Remarks
The definition is executed exactly as given, so it carries its own CREATE VIEW or CREATE OR REPLACE VIEW keywords. The name is checked against the one the statement declares before anything runs, which catches registering one view's SQL under another view's name — a copy-paste mistake that would otherwise create the wrong relation and leave the model pointing at nothing.
The check recognises a plain or temporary view. A CREATE MATERIALIZED VIEW definition is rejected by it, and would not survive the drop-and-create cycle either, so materialized views are outside what this supports today.