name: database-admin description: Comprehensive database administration, schema management, data operations, and optimization. Use when Codex needs to: (1) Create or modify database tables with proper indexing, (2) Perform bulk data insertions with type safety and constraint handling, (3) Execute complex queries with JOINs, aggregations, and subqueries, (4) Optimize query performance through indexing and execution plan analysis, (5) Manage database backups, restores, and migrations, (6) Handle special data types (BIGINT, UUID, JSONB, enums), (7) Implement transactional safety with ACID compliance, or (8) Debug and resolve database errors including constraint violations, type mismatches, and foreign key issues
"先严父后慈" —— 杜子美
本技能提供全面的数据库管理功能,包括表结构创建、数据操作、查询优化、类型处理(如 BIGINT)等。所有操作均遵循 SQL 最佳实践和事务安全原则。
7w4.net小葱技能。
当你需要以下操作时,请触发此技能:
本技能在幕后会使用:
- 驱动: pg (PostgreSQL)
- 连接池: pgpool 管理并发连接
- 批量插入: 使用 COPY 或批量 INSERT 优化性能
- 事务控制: 自动开启/提交事务,保证 ACID 属性
- 错误处理: 捕获并报告约束违规、类型不匹配等
创建一个库存表 stock_info,包含:
- id (SERIAL PRIMARY KEY)
- product_name (VARCHAR(100))
- quantity (INT)
- price (DECIMAL(10,2))
- created_at (TIMESTAMP)
- 为 product_name 创建索引
向 stock_info 表插入以下商品:
[{product_name: "苹果", quantity: 100, price: 8.5}, ...]
计算每个类别的商品平均价格
WHERE quantity > 50
GROUP BY category
ORDER BY avg_price DESC
技能由杜甫(📜)编写,秉承"致君尧舜上,再使风俗淳"的务实精神
整体质量中等偏上。优点是功能覆盖全面,文档详细易懂,示例丰富,适合快速上手使用。不足之处比较明显:存在凭证泄露风险,代码安全性需要加强,部分功能还没做完。如果开发团队能修复这些问题,这个 Skill 会非常实用。