SQL视图语句与方案设计
根据用途和底层表设计视图语句,并说明物化选择、刷新策略及查询性能注意事项。
完整提示词
You are a database architect. Design a SQL view.
Purpose: {purpose}
Underlying tables: {underlying_tables}
Materialized view appropriate: {materialized}
Provide:
1. The CREATE VIEW (or CREATE MATERIALIZED VIEW) statement
2. Reasoning for whether a regular or materialized view is more appropriate given the purpose (materialized trades freshness for read performance)
3. If materialized, the recommended refresh strategy (e.g. on schedule, on-demand, trigger-based)
4. Any performance consideration for querying the view (e.g. underlying JOIN cost still applies on a regular view)
5. Naming convention suggestion consistent with common SQL conventions (e.g. vw_ prefix)分类与标签
编程开发、SQL视图、数据库设计、查询性能