Master relational databases with SQL. Schema design, queries, performance, migrations for PostgreSQL, MySQL, SQLite, SQL Server.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install sql或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install sql⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/sql/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: SQL slug: sql version: 1.0.1 changelog: "Added SQL Server support, schema design patterns, query patterns (CTEs, window functions), operations guide (backup, monitoring, replication)" homepage: https://clawic.com/skills/sql description: Master relational databases with SQL. Schema design, queries, performance, migrations for PostgreSQL, MySQL, SQLite, SQL Server. metadata: {"clawdbot":{"emoji":"🗄️","requires":{"anyBins":["sqlite3","psql","mysql","sqlcmd"]},"os":["linux","darwin","win32"]}} ---
Master relational databases from the command line. Covers SQLite, PostgreSQL, MySQL, and SQL Server with battle-tested patterns for schema design, querying, migrations, and operations.
Working with relational databases—designing schemas, writing queries, building migrations, optimizing performance, or managing backups. Applies to SQLite, PostgreSQL, MySQL, and SQL Server.
| Topic | File | |-------|------| | Query patterns | patterns.md | | Schema design | schemas.md | | Operations | operations.md |
| Use Case | Database | Why | |----------|----------|-----| | Local/embedded | SQLite | Zero setup, single file | | General production | PostgreSQL | Best standards, JSONB, extensions | | Legacy/hosting | MySQL | Wide hosting support | | Enterprise/.NET | SQL Server | Windows integration |
# ❌ NEVER
cursor.execute(f"SELECT * FROM users WHERE id = {user_id}")
# ✅ ALWAYS
cursor.execute("SELECT * FROM users WHERE id = ?", (user_id,))
Any column in WHERE, JOIN ON, or ORDER BY on large tables needs an index.
BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
COMMIT;
-- ✅ Faster (stops at first match)
SELECT * FROM orders o WHERE EXISTS (
SELECT 1 FROM users u WHERE u.id = o.user_id AND u.active
);
---
sqlite3 mydb.sqlite # Create/open
sqlite3 mydb.sqlite "SELECT * FROM users;" # Query
sqlite3 -header -csv mydb.sqlite "SELECT *..." > out.csv
sqlite3 mydb.sqlite "PRAGMA journal_mode=WAL;" # Better concurrency
psql -h localhost -U myuser -d mydb # Connect
psql -c "SELECT NOW();" mydb # Query
psql -f migration.sql mydb # Run file
\dt \d+ users \di+ # List tables/indexes
mysql -h localhost -u root -p mydb # Connect
mysql -e "SELECT NOW();" mydb # Query
sqlcmd -S localhost -U myuser -d mydb # Connect
sqlcmd -Q "SELECT GETDATE()" # Query
sqlcmd -S localhost -d mydb -E # Windows auth
---
NOT IN (subquery) returns empty if subquery has NULL → use NOT EXISTSNULL = NULL is NULL, not true → use IS NULLCOUNT(column) excludes NULLs, COUNT(*) counts allWHERE YEAR(date) = 2024 scans full tableWHERE varchar_col = 123 skips indexLIKE '%term' can't use index → only LIKE 'term%' works(a, b) won't help filtering only on b---
-- PostgreSQL
EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM orders WHERE user_id = 5;
-- SQLite
EXPLAIN QUERY PLAN SELECT * FROM orders WHERE user_id = 5;
Red flags:
Seq Scan on large tables → needs indexRows Removed by Filter high → index doesn't cover filterANALYZE tablename;---
-- Composite index (equality first, range last)
CREATE INDEX idx_orders ON orders(user_id, status);
-- Covering index (avoids table lookup)
CREATE INDEX idx_orders ON orders(user_id) INCLUDE (total);
-- Partial index (smaller, faster)
CREATE INDEX idx_pending ON orders(user_id) WHERE status = 'pending';
---
| Feature | PostgreSQL | MySQL | SQLite | SQL Server | |---------|------------|-------|--------|------------| | LIMIT | LIMIT n | LIMIT n | LIMIT n | TOP n | | UPSERT | ON CONFLICT | ON DUPLICATE KEY | ON CONFLICT | MERGE | | Boolean | true/false | 1/0 | 1/0 | 1/0 | | Concat | \|\| | CONCAT() | \|\| | + |
---
Install with clawhub install if user confirms:
prisma — Node.js ORMsqlite — SQLite-specific patternsanalytics — data analysis queriesclawhub star sqlclawhub sync安装 SQL 后,可以对 AI 说这些话来触发它
Help me get started with SQL
Explains what SQL does, walks through the setup, and runs a quick demo based on your current project
Use SQL to master relational databases with SQL
Invokes SQL with the right parameters and returns the result directly in the conversation
What can I do with SQL in my developer & devops workflow?
Lists the top use cases for SQL, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/sql/ 目录(个人级,所有项目可用),或 .claude/skills/sql/(项目级)。重启 AI 客户端后,用 /sql 主动调用,或让 AI 根据上下文自动发现并使用。
SQL 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
SQL 可免费安装使用。请查阅仓库了解许可证信息。
Master relational databases with SQL. Schema design, queries, performance, migrations for PostgreSQL, MySQL, SQLite, SQL Server.
SQL 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using SQL
Identifies repetitive steps in your workflow and sets up SQL to handle them automatically