技能 sql-expert
🗄️

sql-expert

低风险 ⚡ 包含脚本📁 文件系统访问

編寫和優化 SQL 查詢

也可从以下获取: hmohamed01

編寫複雜的 SQL 查詢和優化資料庫效能需要深入了解查詢模式、索引策略和資料庫特定語法。此技能提供專家指導,幫助建立高效能查詢、設計正規化結構,以及疑難排解 PostgreSQL、MySQL、SQLite 和 SQL Server 的效能問題。

支持: Claude Codex Code(CC)
🥈 79 白银
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“sql-expert”。 Write a query to find the top 5 customers by order total with their last order date

预期结果:

  • Query uses a CTE to aggregate order totals per customer
  • Uses ROW_NUMBER() window function for ranking
  • Includes proper JOIN between customers and orders tables
  • Filters to top 5 with ORDER BY and LIMIT

正在使用“sql-expert”。 Design a schema for a library management system with books, authors, and borrowers

预期结果:

  • Creates books table with ISBN, title, and publication year
  • Creates authors table with name and biography
  • Creates junction table for book-author relationships
  • Adds foreign key constraints for data integrity

正在使用“sql-expert”。 Explain why this query is slow and how to fix it

预期结果:

  • Query performs full table scan on large table
  • Missing index on filtered column causes performance issue
  • Suggest creating index on status and created_at columns
  • Recommend using LIMIT for exploratory queries

安全审计

低风险
v5 • 1/16/2026

This is a legitimate educational SQL skill containing SQL documentation, patterns, and a Python helper utility using SQLAlchemy ORM with parameterized queries. All static findings are false positives caused by the scanner incorrectly flagging SQL keywords as cryptographic algorithms and system reconnaissance patterns. No malicious code or behaviors detected. Behavior matches stated purpose.

12
已扫描文件
5,257
分析行数
2
发现项
5
审计总数

风险因素

⚡ 包含脚本 (1)
📁 文件系统访问 (1)
审计者: claude 查看审计历史 →

质量评分

82
架构
100
可维护性
85
内容
26
社区
90
安全
87
规范符合性

你能构建什么

查詢參考

快速找到正確的 SQL 語法,用於連接、聚合和複雜查詢

效能調優

使用 EXPLAIN 計劃、索引建議和查詢模式優化慢速查詢

結構和遷移

設計正規化結構並建立安全、零停機時間的遷移腳本

试试这些提示

基本查詢
Write a SQL query to select [columns] from [table] where [condition] and order by [column] limit [number]
複雜分析
Write a query using window functions to calculate [ranking/running total/percentile] partitioned by [column] ordered by [column]
結構設計
Design SQL tables for [use case] following third normal form with proper foreign keys and constraints
效能審查
Analyze this query for performance issues and suggest optimizations using indexes and query restructuring: [paste query]

最佳实践

  • 始終使用參數化查詢以防止 SQL 注入攻擊
  • 為外鍵欄位和經常篩選的欄位建立索引以獲得更好的效能
  • 對相關操作使用交易以確保原子性

避免

  • 避免使用 SELECT * - 只指定需要的欄位以減少資料傳輸
  • 不要在 WHERE 子句中的索引欄位上使用函數
  • 切勿將使用者輸入直接串接到 SQL 查詢字串中

常见问题

支援哪些資料庫?
支援 PostgreSQL、MySQL、SQLite 和 SQL Server,並提供特定方言的語法和函數
此技能如何優化查詢?
使用 EXPLAIN 計劃分析、識別缺失的索引並建議重寫查詢
我可以和 SQLAlchemy 之類的 ORM 一起使用嗎?
是的,輔助腳本與 SQLAlchemy 整合,可用於基於 ORM 的資料庫操作
我的資料安全嗎?
技能僅提供模式和指導。查詢不會在未經您明確操作的情況下在您的資料庫上執行
為什麼我的查詢很慢?
常見原因包括缺失索引、全表掃描或低效的 JOIN。使用 EXPLAIN 識別瓶頸
如何正確處理 NULL 值?
使用 IS NULL 和 IS NOT NULL 進行比較。使用 COALESCE 提供預設值