Syntax
CREATE VIEW
features:
- Schema-qualified names: Views can be defined in specific schemas
- OR REPLACE: Optional clause to replace an existing view definition
- AS clause: Any valid SELECT statement that defines the view’s contents
- View dependencies: Proper handling of view-to-view dependencies
Canonical Format
When generating migration SQL, pgschema produces views in the following canonical format:- Always uses
CREATE OR REPLACE VIEW
for creation and modifications - Schema qualification included when necessary
- Preserves the original SELECT statement formatting
- For DROP operations:
DROP VIEW IF EXISTS view_name CASCADE;
CREATE OR REPLACE
, allowing seamless updates to view definitions without dropping dependent objects. pgschema leverages this feature for efficient view migrations.