Views are virtual tables based on query results.Documentation Index
Fetch the complete documentation index at: https://docs.omniql.com/llms.txt
Use this file to discover all available pages before exploring further.
Basic Syntax
Create View
| Database | Output |
|---|---|
| PostgreSQL | CREATE VIEW activeuser AS SELECT * FROM users WHERE active = true |
| MySQL | CREATE VIEW activeuser AS SELECT * FROM users WHERE active = true |
View with Columns
| Database | Output |
|---|---|
| PostgreSQL | CREATE VIEW usersummary AS SELECT id, name, email FROM users WHERE active = true |
View with Aggregation
| Database | Output |
|---|---|
| PostgreSQL | CREATE VIEW ordertotals AS SELECT user_id, SUM(amount) AS total_spent FROM orders GROUP BY user_id |
Views with COUNT(*) require native SQL. Use SUM, AVG, MIN, MAX with OmniQL views.
Query a View
Views are queried like regular tables.Alter View
Update an existing view definition.| Database | Output |
|---|---|
| PostgreSQL | CREATE OR REPLACE VIEW activeuser AS SELECT * FROM users WHERE active = true AND verified = true |
| MySQL | CREATE OR REPLACE VIEW activeuser AS SELECT * FROM users WHERE active = true AND verified = true |
Drop View
| Database | Output |
|---|---|
| PostgreSQL | DROP VIEW IF EXISTS activeuser |
| MySQL | DROP VIEW IF EXISTS activeuser |
Complete Examples
Active Premium Users
Low Stock Products
Revenue by Status
Limitations
Current view implementation supports:- Simple SELECT queries with WHERE, ORDER BY, LIMIT
- Column selection
- Aggregations with SUM, AVG, MIN, MAX
- COUNT(*) aggregations (use native SQL)
- Views with JOINs (use native SQL)
- Materialized views (PostgreSQL-specific, use native SQL)
- CREATE OR REPLACE (use ALTER VIEW instead)
MongoDB Note
MongoDB does not support traditional views. Use aggregation pipelines or read-only collections for similar functionality.Next Steps
Indexes
Optimize query performance
Transactions
Group operations safely

