# QueryInterface.createView() method · @imqueue/pg-sequelize

Source: https://imqueue.org/api/pg-sequelize/latest/pg-sequelize.queryinterface.createview/
Published: 2026-08-01
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/pg-sequelize 4.2.0 — generated reference, not hand-written

Creates a view from a complete SQL definition.

**Signature:**

```typescript
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.

