coding•5 prompts
AI SQL Prompts
SQL is where AI provides the most immediate productivity boost. Describe what you want in plain English and get optimized queries, even for complex multi-table joins and window functions.
1. Query from Plain English
Best: ChatGPTWrite a SQL query that [describe in plain English what you want]. My tables: [list table names and key columns, or paste CREATE TABLE statements]. Database: [PostgreSQL/MySQL/SQLite]. Include comments explaining each section. If the query needs multiple steps, use CTEs for readability.
Include your table schema and sample data. ChatGPT generates clean, well-commented SQL.
2. Query Performance Optimizer
Best: DeepSeekThis query is slow: [paste query]. Execution time: [current time]. Table sizes: [row counts]. Current indexes: [list]. Diagnose why it's slow, rewrite it for performance, explain what indexes to add, and estimate the improvement. Show the execution plan logic. Database: [type and version].
Include EXPLAIN output if available. DeepSeek excels at identifying query plan inefficiencies.
3. Database Schema Designer
Best: ClaudeDesign a database schema for [application type]. Requirements: [list key entities and relationships]. Consider: normalization (3NF unless you justify denormalization), indexing strategy, common query patterns I'll need, and scalability to [expected data volume]. Provide CREATE TABLE statements with constraints and a brief ERD description.
Describe your most common queries. Claude designs schemas that are normalized but practical.
4. Complex Reporting Query
Best: ClaudeBuild a reporting query that shows: [describe desired report output]. Data sources: [tables and relationships]. Include: aggregations by [dimensions], year-over-year comparison, running totals using window functions, and NULL handling. Format the output for [downstream tool - e.g., "Excel pivot table" or "dashboard API"]. Use CTEs for readability.
Describe the final report layout. Claude structures complex queries with clear CTEs.
5. Data Migration Script
Best: ClaudeWrite a SQL migration script from [old schema] to [new schema]. Old structure: [describe]. New structure: [describe]. Handle: data type conversions, splitting/merging columns, default values for new required fields, referential integrity during migration, and a rollback strategy. Include verification queries to confirm the migration worked.
Include sample data from the old schema. Claude handles edge cases in migrations carefully.
Try These Prompts with Multiple AIs
Get responses from Claude, ChatGPT, Gemini, and more—all at once. Compare which AI handles these prompts best.
Try Council Free