🗃 DB2
DB2 Views
Intermediate 🕑 12 min read
👁 0 views
12
Code Example
## DB2 Views
Views are virtual tables based on SELECT statements.
### Create View
\`\`\`sql
CREATE VIEW view-name AS
SELECT ...
\`\`\`
### View Benefits
1. **Security**: Limit data access
2. **Simplicity**: Hide complex joins
3. **Consistency**: Standard data presentation
4. **Independence**: Insulate from changes
### Updatable Views
Simple views can support INSERT/UPDATE/DELETE:
- Single base table
- No aggregate functions
- No DISTINCT
- All NOT NULL columns included
### WITH CHECK OPTION
Ensures inserts/updates satisfy view WHERE clause.
### Read-Only Views
Views with joins, aggregates, UNION are read-only.