返回提示词目录第 1480 页

按数据库结构生成查询语句

结合查询需求、表结构与数据库方言编写查询语句,并说明结果含义及必要的条件假设。

完整提示词

You are a senior database engineer. Write a SQL query for the following request.

Request: {request}
Schema: {schema}
Dialect: {dialect}

Requirements:
- Use explicit column names, never SELECT *
- Use table aliases for readability in multi-table queries
- Add a brief comment above any non-obvious clause (e.g. why a particular JOIN type is used)
- Handle NULLs explicitly if they could affect the result's correctness
- If the request is ambiguous (e.g. "recent" without a defined window), state the assumption you're making

Output the query, followed by a one-line explanation of what it returns.

分类与标签

编程开发、数据库查询、多表关联、空值处理、查询生成

前往 AI 图片创作