sql-assistant
Comprehensive SQL query assistant for database operations, optimization, and troubleshooting. Use when Codex needs to write, debug, optimize, or explain SQL queries; analyze database schemas; or help with SQL-related tasks including joins, subqueries, aggregations, and performance tuning. Supports MySQL, PostgreSQL, SQLite, and other SQL dialects.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/hhhh124hhhh/sql-assistantSQL Assistant
Overview
This skill provides Codex with deep SQL expertise to help users with all database-related tasks: writing efficient queries, debugging errors, optimizing performance, explaining complex queries, and designing database schemas. Based on best practices from database administrators and SQL optimization experts.
Core Capabilities
1. Query Writing
Write clean, efficient SQL queries based on user requirements:
Basic Query Construction:
User: "Show me all users who signed up in the last 7 days"
Codex: SELECT * FROM users WHERE created_at >= DATE('now', '-7 days');
Complex Queries:
- Joins: Inner, left, right, full outer joins
- Subqueries: Nested queries, correlated subqueries
- Aggregations: GROUP BY, HAVING, window functions
- CTEs: Common Table Expressions for complex logic
- Unions: Combining results from multiple queries
Example Multi-Join Query:
SELECT
u.name,
COUNT(o.id) AS order_count,
SUM(o.total) AS total_spent
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.created_at >= '2024-01-01'
GROUP BY u.id, u.name
HAVING COUNT(o.id) > 0
ORDER BY total_spent DESC
LIMIT 10;
2. Query Debugging
Identify and fix common SQL errors:
Common Errors to Fix:
- Syntax errors (missing commas, unbalanced parentheses)
- Column/table name typos
- Invalid data type usage
- Missing FROM clauses
- Incorrect GROUP BY usage
- Unquoted string literals
Debugging Process:
- Analyze the error message
- Identify the root cause
- Explain why the error occurred
- Provide the corrected query
- Explain the fix to help the user learn
Example:
User: SELECT * FROM users WHERE created_at = '2024-01-01' AND status = active
Error: column "active" does not exist
Codex: The issue is that 'active' should be quoted as a string literal:
SELECT * FROM users WHERE created_at = '2024-01-01' AND status = 'active';
Without quotes, SQL treats 'active' as a column name rather than a string value.
3. Query Optimization
Improve query performance through indexing and rewriting:
Optimization Strategies:
- Indexing: Add indexes on frequently filtered columns
- Query Rewriting: Use efficient patterns (EXISTS vs IN, etc.)
- Subquery Optimization: Convert subqueries to joins when beneficial
- Limit Results: Use LIMIT/OFFSET or pagination
- **Avoid SELECT ***: Only select needed columns
- Proper Join Order: Join smaller tables first
Before Optimization:
SELECT * FROM orders o
WHERE user_id IN (SELECT id FROM users WHERE status = 'active');
After Optimization:
SELECT o.* FROM orders o
JOIN users u ON o.user_id = u.id
WHERE u.status = 'active';
-- Better performance because:
-- 1. Uses indexed join instead of subquery
-- 2. Database can optimize the join execution plan
-- 3. Potentially uses existing indexes on both tables
4. Query Explanation
Break down complex queries in plain English:
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-hhhh124hhhh-sql-assistant": {
"enabled": true,
"auto_update": true
}
}
}Related Skills
ai-music-prompts
AI music prompt templates and best practices for generating music with AI tools like Suno, Udio, Mureka, and others. Use when user needs to create music prompts, song ideas, or wants guidance on writing effective prompts for AI music generation. Includes bilingual prompt templates for various genres, mood descriptors, instrumentation guidance, and lyric writing tips. Also provides techniques for crafting specific musical outcomes and examples of well-structured prompts in Chinese and English.
Cinematic Product Film
Skill by hhhh124hhhh
tiktok-ai-model-generator
Generate AI model videos for TikTok livestreams using Pinterest, Claude, Nano Banana Pro, and Veo or Kling. Use for creating AI-generated fashion models wearing products, animating them into videos, or building automated TikTok content production workflows. This skill provides a complete 4-step workflow covering Pinterest reference selection, Claude JSON prompt generation, Nano Banana Pro image generation, and video animation. Perfect for e-commerce sellers, content creators, and TikTok marketers who need AI models to showcase products.
Lifestyle Product Shot
Skill by hhhh124hhhh
50-viral-gemini-ai-prompts-ready-to-copy-paste-for-e7b5d316
Romantic couple hugging on a beach at sunset, cinematic lighting, soft focus, using reference faces