MCPInstall

oracle

Provides comprehensive guidance for Oracle database including SQL, PL/SQL, functions, performance tuning (AWR/ASH), backup (RMAN), Data Guard, and RAC. Use when the user asks about Oracle, needs to write Oracle SQL, work with PL/SQL, or manage Oracle databases.

Installs
88
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/full-stack-skills/database-skills --skill oracle
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads oracle automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Oracle Database — 企业级关系型数据库

Oracle Database 是全球领先的企业级关系型数据库管理系统,以其高可用性、高性能、强安全性及丰富的功能集(RAC、Data Guard、Flashback、高级分区、物化视图等)著称。

Workflow — 使用决策树

遇到 Oracle 相关需求时,按以下顺序决策:

Step 1: 明确场景
├── 编写 SQL 查询/DDL/DML?       → references/09-sql-syntax.md
├── 使用内置函数?                  → 字符串/日期/聚合 → references/01-functions-string.md / 02-functions-date.md
├── 窗口/分析函数?                 → references/03-analytic-functions.md
├── 编写 PL/SQL?                  → references/04-plsql-guide.md
├── 性能调优/执行计划?             → references/05-performance-tuning.md
├── 备份恢复?                     → references/06-backup-recovery.md
├── Data Guard / RAC?             → references/07-dataguard-rac.md
├── 安全/权限/审计?                → references/08-security.md
└── 分区/物化视图/Flashback/AQ?   → references/10-features.md

Step 2: 选择工具
├── 交互式查询 → SQL*Plus / SQL Developer / DBeaver
├── 批量脚本   → SQL*Plus 静默模式
├── PL/SQL 调试 → SQL Developer / TOAD / PL/SQL Developer
└── 自动化运维 → OEM / 脚本

Step 3: 确定环境
├── 版本 → 19c (LTS), 21c/23c (最新)
├── 架构 → 单实例 / RAC / Data Guard / RAC+DG
├── CDB/PDB? → 12c+ 多租户
└── 字符集 → AL32UTF8, ZHS16GBK

When to Use / When NOT to

✅ Use When❌ Skip When
企业级事务处理(ACID 严格保证)简单键值缓存(用 Redis)
复杂 SQL、多表 JOIN、报表分析文档存储(用 MongoDB)
PL/SQL 存储过程/包/触发器全文搜索为主(用 Elasticsearch)
海量数据分区(TB/PB 级)实时内存计算(用 Redis/Spark)
高可用(RAC/Data Guard)轻量嵌入式(用 SQLite)
数据仓库/OLAP 分析时序数据(用 InfluxDB/TimescaleDB)
数据安全与审计(TDE/FGA/VPD)简单 CRUD 快速开发(用 PostgreSQL)
大规模 OLTP 交易系统仅需文档型层次化数据(用 PostgreSQL JSONB)

Boundary — 能力边界

✅ 完全适用⚠️ 有条件适用❌ 不适用
OLTP/OLAP 混合负载海量非结构化数据(用对象存储)代替 Redis 做内存缓存
复杂事务与数据一致性跨数据库异构集成(GoldenGate/DB Link)实时流处理(Kafka/Storm)
PL/SQL 业务逻辑封装多写场景(RAC 共享存储写)简单 CRUD 原型快速迭代
数据分区与物化视图地理分布式多活(用 GoldenGate)多模型数据统一管理
RAC 集群高可用超低延迟(<100μs)查询替代搜索引擎做全文搜索
细粒度安全审计作为文档数据库存大量 JSON替代对象存储

超出范围时请考虑:PostgreSQL(开源关系型)、MongoDB(文档)、Redis(缓存)、Elasticsearch(全文搜索)、MySQL(轻量 Web)。


SQL 语法速查

Oracle 的 SQL 差异主要体现在以下方面。完整内容见 references/09-sql-syntax.md。

特性说明参考文件
数据类型VARCHAR2, NUMBER, CLOB, BLOB, TIMESTAMP, INTERVALreferences/09-sql-syntax.md
序列CREATE SEQUENCE 替代 AUTO_INCREMENTreferences/09-sql-syntax.md
MERGEUPSERT(存在则更新,不存在则插入)references/09-sql-syntax.md
INSERT ALL多表条件插入references/09-sql-syntax.md
CONNECT BY层次查询(组织树)references/09-sql-syntax.md
PIVOT/UNPIVOT行转列/列转行references/09-sql-syntax.md
LISTAGG列转字符串聚合references/09-sql-syntax.md
MODEL 子句电子表格式跨行计算references/09-sql-syntax.md
MATCH_RECOGNIZE模式匹配(12c+)references/09-sql-syntax.md
FLASHBACK QUERY闪回查询历史数据references/09-sql-syntax.md
WITH (CTE) / 递归 CTE公用表表达式references/09-sql-syntax.md
伪列ROWNUM, ROWID, LEVEL, ORA_ROWSCNreferences/09-sql-syntax.md
集合操作UNION, INTERSECT, MINUS(Oracle 差集)references/09-sql-syntax.md

函数速查

类别关键函数参考文件
字符串SUBSTR, INSTR, REPLACE, REGEXP_LIKE/SUBSTR/REPLACE, TRANSLATE, LISTAGGreferences/01-functions-string.md
数字ROUND, TRUNC, MOD, CEIL, FLOOR, POWER, GREATEST/LEASTreferences/01-functions-string.md
日期SYSDATE, EXTRACT, TO_DATE/TO_CHAR, ADD_MONTHS, MONTHS_BETWEEN, LAST_DAY, NEXT_DAY, TRUNC 日期版references/02-functions-date.md
转换TO_CHAR/TO_NUMBER/TO_DATE, CAST, CONVERT, SCN_TO_TIMESTAMPreferences/02-functions-date.md
NULL 处理NVL, NVL2, COALESCE, NULLIF, LNNVLreferences/01-functions-string.md
聚合COUNT, SUM, AVG, MEDIAN, STATS_MODE, ROLLUP/CUBE, GROUPINGreferences/03-analytic-functions.md
分析/窗口ROW_NUMBER, RANK, DENSE_RANK, NTILE, LAG/LEAD, FIRST_VALUE/LAST_VALUE, RATIO_TO_REPORTreferences/03-analytic-functions.md

高级特性索引

特性说明参考文件
PL/SQL 块结构DECLARE/BEGIN/EXCEPTION/ENDreferences/04-plsql-guide.md
游标 (Cursor)显式/隐式/REF CURSOR/SYS_REFCURSORreferences/04-plsql-guide.md
存储过程/函数CREATE OR REPLACE PROCEDURE/FUNCTIONreferences/04-plsql-guide.md
包 (Package)规范+体,封装/重载/全局变量references/04-plsql-guide.md
触发器 (Trigger)DML/INSTEAD OF/DDL/系统事件references/04-plsql-guide.md
集合类型关联数组/嵌套表/VARRAYreferences/04-plsql-guide.md
动态 SQLEXECUTE IMMEDIATE / DBMS_SQL / FORALL / BULK COLLECTreferences/04-plsql-guide.md
异常处理预定义/自定义/RAISE_APPLICATION_ERRORreferences/04-plsql-guide.md
EXPLAIN PLAN / DBMS_XPLAN执行计划查看与分析references/05-performance-tuning.md
AWR/ASH/ADDM性能历史/活跃会话/自动诊断references/05-performance-tuning.md
SQL Tuning Advisor自动 SQL 优化建议references/05-performance-tuning.md
DBMS_STATS统计信息收集与管理references/05-performance-tuning.md
SPM (SQL Plan Management)执行计划基线管理references/05-performance-tuning.md
RMAN全库/增量备份与恢复references/06-backup-recovery.md
EXPDP/IMPDP逻辑备份导入导出references/06-backup-recovery.md
归档日志模式ARCHIVELOG / NOARCHIVELOGreferences/06-backup-recovery.md
Data Guard物理备库/逻辑备库/Switchover/Failoverreferences/07-dataguard-rac.md
RAC集群/序列配置/全局等待references/07-dataguard-rac.md
用户/角色/权限系统权限/对象权限/Profilereferences/08-security.md
FGA (细粒度审计)基于条件的 SQL 审计references/08-security.md
VPD (虚拟私有数据库)行级安全策略references/08-security.md
数据脱敏 (Data Redaction)动态数据掩码references/08-security.md
TDE (透明数据加密)列级/表空间级加密references/08-security.md
表空间与数据文件CREATE/ALTER TABLESPACEreferences/10-features.md
分区表RANGE/LIST/HASH/复合/间隔分区references/10-features.md
索引B-Tree/位图/函数/域索引references/10-features.md
物化视图查询重写/快速刷新/ON COMMITreferences/10-features.md
Flashback闪回查询/表/删除/数据库references/10-features.md
AQ (高级队列)消息队列references/10-features.md

Gotchas — 常见陷阱

#问题风险解决方案
1ROWNUM ORDER BY 顺序错误不是 Top-N子查询排序或 FETCH FIRST(12c+)
2隐式类型转换导致索引失效全表扫描WHERE hire_date = TO_DATE('2024-01-15','YYYY-MM-DD')
3NOT IN 子查询含 NULL 返回空数据丢失用 NOT EXISTS 替代
4SELECT INTO 无数据抛出 NO_DATA_FOUND过程终止提前检查或用 EXCEPTION 捕获
5绑定变量窥视执行计划偏差用 ACS / SQL Profile
6统计信息过旧优化器选错计划定期 DBMS_STATS 收集
7OLTP 用位图索引行锁阻塞OLTP 用 B-Tree 索引
8UPDATE 大量行不用 FORALL性能极差用 FORALL 批量 DML
9忽略分区裁剪全分区扫描WHERE 条件含分区键
10触发器递归/变异表 (ORA-04091)触发器失败复合触发器/自治事务/语句级
11SELECT * 在视图/过程中结构变更后行为异常显式列出列名
12大量 DISTINCT 掩盖 JOIN 不当性能开销大检查 JOIN 条件
13物化视图 ON COMMIT 刷新影响 DML 性能写操作拖慢建日志 + ON DEMAND 定时刷新
14WHERE 中对列应用函数索引失效改写为范围查询
15DBMS_OUTPUT 打印大量数据缓冲区溢出仅调试用,生产用日志表

FAQ

Q1: VARCHAR2 和 NVARCHAR2 区别? VARCHAR2 使用数据库字符集(AL32UTF8/ZHS16GBK),NVARCHAR2 使用国家字符集(AL16UTF16)。推荐一般场景用 VARCHAR2,多语言用 NVARCHAR2。

Q2: ROWNUM 和 ROW_NUMBER() 区别? ROWNUM 是伪列(先分配后排序),ROW_NUMBER() 是分析函数(排序后分配序号)。

Q3: Oracle vs PostgreSQL 主要差异?

特性OraclePostgreSQL
自增SEQUENCE / IDENTITY (12c+)SERIAL / GENERATED AS IDENTITY
字符串VARCHAR2VARCHAR / TEXT
空串'' = NULL'' ≠ NULL
递归CONNECT BY / WITH RECURSIVEWITH RECURSIVE
分页ROWNUM / FETCH FIRSTLIMIT/OFFSET
UPSERTMERGEINSERT...ON CONFLICT
表空间有无

Q4: UNDO 和 REDO 区别? REDO 记录变更(重做/恢复),UNDO 记录变更前数据(回滚/一致性读/闪回)。

Q5: 何时用物化视图? 查询大聚合可接受延迟、基表变更不频繁、需要跨数据库缓存、需要查询重写。

Q6: 分区表常见误区? 分区不保证查询加速(需分区键)、不能解决所有大表问题、分区不是越多越好、OLTP 也适合分区。

Q7: 什么是读一致性? Oracle 通过 UNDO 实现 SELECT 不加锁也不被写阻塞,查询使用查询开始时的 SCN 读取一致性版本。

Q8: 死锁如何处理? Oracle 3 秒内自动检测,回滚牺牲品语句并抛 ORA-00060。最佳实践:统一访问顺序、事务简短。

Q9: CDB 和 PDB 是什么? 12c+ 多租户:CDB = 容器数据库,PDB = 可插拔数据库。一个 CDB 最多 4096 个 PDB。

Q10: KILL SESSION 后连接未断开? 标记为 KILLED,下次执行 SQL 时断开。KILL SESSION 'sid,serial#' IMMEDIATE 可立即断开。

Q11: REDO 日志切换太频繁? 增加 REDO 日志大小(建议 15-30 分钟切换一次)、增加日志组数(至少 3-4 组)。

Q12: ORA-01555 "Snapshot Too Old"? UNDO 数据被覆盖。增大 UNDO 表空间、减少 UNDO_RETENTION、优化长查询。

Q13: Oracle 中如何实现分页? SELECT * FROM (SELECT t.*, ROWNUM AS rn FROM (SELECT ... ORDER BY col) t) WHERE rn BETWEEN 11 AND 20 或 12c+ OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY。

Q14: 什么是 FORCE LOGGING? 强制所有 DML 写 REDO(即使是 NOLOGGING 操作),Data Guard 环境要求开启。

Q15: 如何查看当前数据库版本? SELECT * FROM v$version; 或 SELECT banner FROM v$version WHERE banner LIKE 'Oracle%';


Keywords

oracle, Oracle Database, PL/SQL, SQL*Plus, RAC, Data Guard, ADG, RMAN, expdp, impdp, flashback, AWR, ASH, ADDM, DBMS_XPLAN, VARCHAR2, NUMBER, CLOB, SEQUENCE, SYNONYM, CONNECT BY, PIVOT, LISTAGG, MERGE, INSERT ALL, MODEL, MATCH_RECOGNIZE, 分析函数, 窗口函数, ROW_NUMBER, RANK, LAG, LEAD, 存储过程, 包, 触发器, 游标, REF CURSOR, 动态SQL, FORALL, BULK COLLECT, 分区表, 物化视图, 位图索引, 表空间, TDE, FGA, VPD, DBMS_STATS, SPM, CDB, PDB, 多租户, UNDO, REDO, 读一致性, ORA-01555

References

  • references/01-functions-string.md — 字符串/数字/NULL 处理函数
  • references/02-functions-date.md — 日期/转换函数
  • references/03-analytic-functions.md — 分析函数(窗口函数)+ 聚合
  • references/04-plsql-guide.md — PL/SQL 详解
  • references/05-performance-tuning.md — 性能调优
  • references/06-backup-recovery.md — 备份恢复
  • references/07-dataguard-rac.md — Data Guard / RAC
  • references/08-security.md — 安全与权限
  • references/09-sql-syntax.md — SQL 语法详解
  • references/10-features.md — 特有特性(分区/物化视图/Flashback/AQ)
  • examples/01-plsql-procedure.md — PL/SQL 存储过程示例
  • examples/02-awr-analysis.md — AWR 性能分析示例
  • examples/03-rman-backup.md — RMAN 备份示例
  • examples/04-dataguard-setup.md — Data Guard 搭建示例
  • Oracle 19c 官方文档
  • Oracle Live SQL (在线练习)

FAQ

What does the oracle skill do?

Provides comprehensive guidance for Oracle database including SQL, PL/SQL, functions, performance tuning (AWR/ASH), backup (RMAN), Data Guard, and RAC. Use when the user asks about Oracle, needs to write Oracle SQL, work with PL/SQL, or manage Oracle databases.

How do I install oracle?

Run npx skills add https://github.com/full-stack-skills/database-skills --skill oracle in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/oracle/ (personal) or .claude/skills/oracle/ (project).

Which AI agents can use oracle?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is oracle safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains oracle?

It is published by full-stack-skills in full-stack-skills/database-skills. It has 88 recorded installs.

More from full-stack-skills/database-skills

View all →

postgresql

full-stack-skills/database-skills

Provides comprehensive guidance for PostgreSQL including SQL syntax, advanced features (JSONB/CTE/Full-text), functions, indexing, performance tuning, replication, and backup. Use when the user asks about PostgreSQL, needs to work with PostgreSQL features, write complex queries, or optimize PostgreSQL databases.

Data & Databases114 installs

mysql

full-stack-skills/database-skills

Provides comprehensive guidance for MySQL including SQL syntax, functions, indexing, optimization, replication, backup, and high availability. Use when the user asks about MySQL, needs to write MySQL queries, design database schemas, optimize performance, or manage MySQL databases.

Data & Databases106 installs

redis

full-stack-skills/database-skills

Open the skill to read its SKILL.md instructions.

Data & Databases90 installs

elasticsearch

full-stack-skills/database-skills

Open the skill to read its SKILL.md instructions.

Data & Databases78 installs

Popular data & databases skills

View category →

Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pgcron, pgmq), vector/semantic search (pgvector), and restoring dumps (pgrestore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.

OfficialData & Databases462.2K installs

prisma-client-api

prisma/skills

Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".

OfficialData & Databases393.5K installs

Deprecated compatibility name for prisma-orm-setup. Use only when a user or existing integration explicitly invokes prisma-database-setup; otherwise select prisma-orm-setup.

OfficialData & Databases392.3K installs

prisma-cli

prisma/skills

Prisma ORM 7 CLI reference for existing Prisma 7 applications or explicitly selected Prisma 7 workflows. Covers prisma init, generate, migrate, db, dev, studio, and mcp. For setup, connection repair, or Prisma 8, use prisma-orm-setup; not the Prisma Platform CLI.

OfficialData & Databases390.8K installs

prisma-postgres

prisma/skills

Deprecated compatibility name for prisma-postgres-setup. Use only when a user or existing integration explicitly invokes prisma-postgres; otherwise select prisma-postgres-setup.

OfficialData & Databases384.4K installs

Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, original database-error preservation, and verification.

OfficialData & Databases378.9K installs