AI-Powered Version Control for Oracle Database using Claude Desktop + SQLcL MCP + Oracle Database Skills
In this guide, we will build a human-in-the-loop AI-driven version control system for Oracle Database using Claude Desktop, SQLcl MCP, and Git.
This setup allows Claude to:
- Extract clean and consistent schema DDL
- Detect changes between versions
- Analyze risks and anti-patterns
- Recommend whether a change should be committed or reverted
How it works: Claude first reads a version control skill file that defines exactly how DDL should be extracted — removing unnecessary storage clauses, avoiding schema prefixes, and ensuring one object per file.
It then:
- Uses SQLcl MCP to query the database
- Uses Filesystem MCP to write versioned
.sqlfiles - Waits for you to run Git commands manually
- Analyzes git diff output that you provide
This creates a workflow similar to a pull request review system — but for database schema changes.
Prerequisites
Ensure the following are installed and configured properly:
- Oracle Database (Local / Docker)
- SQLcl installed and accessible via command line
- Git installed and configured
- Node.js (required for MCP servers)
- Claude Desktop with MCP enabled
1. Configure Claude Desktop
Update your claude_desktop_config.json as shown below.
This configuration:
- Enables SQLcl as a database interaction layer
- Grants Claude controlled access to local directories
- Defines where schema files will be stored
{
"mcpServers": {
"sqlcl": {
"command": "C:/Oracle/sqlcl/bin/sql",
"args": ["-mcp"]
},
"oracle-skills": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"C:/oracle-db-skills",
"C:/db-version-control"
]
}
}
}
2. Human-in-the-Loop Workflow (No Shell MCP Needed)
In this architecture, Claude is responsible for analysis and guidance, not execution.
- Claude extracts schema and writes files
- You execute Git commands manually
- Claude reviews changes and provides recommendations
This approach ensures:
- Full developer control over version history
- No risk of unintended command execution
- Clear and auditable decision-making process
3. Initialize Local Repository
Create a dedicated directory to store version-controlled database objects.
mkdir C:\db-version-control
cd C:\db-version-control
git init
Organize objects by type for better maintainability:
mkdir views
mkdir indexes
4. Create Demo Objects
Run the following SQL statements to create sample objects that we will track and analyze.
CREATE INDEX IDX_EMP_HIRE_DATE ON EMPLOYEES(HIRE_DATE);
CREATE OR REPLACE VIEW VW_EMP_DEPT_SUMMARY AS
SELECT
e.EMPLOYEE_ID,
e.EMPLOYEE_NAME,
e.SALARY,
e.HIRE_DATE,
d.DEPARTMENT_ID,
d.DEPARTMENT_NAME
FROM EMPLOYEES e
JOIN DEPARTMENTS d
ON e.DEPARTMENT_ID = d.DEPARTMENT_ID;
5. Generate Baseline Snapshot (Claude Prompt)
Claude will now extract the current schema state and write clean DDL files.
The skill file ensures:
- No storage-specific noise
- No schema prefixes
- One object per file
Read C:/oracle-db-skills/skills/devops/version-control-sql.md first, then use it to take a baseline version control snapshot of demo_schema.
Objects to capture:
- VIEW: VW_EMP_DEPT_SUMMARY
- INDEX: IDX_EMP_HIRE_DATE
Output directory: C:/db-version-control
Once files are generated, commit them manually:
git add .
git commit -m "snapshot: baseline demo schema"
6. Apply a Good Change
This change introduces a performance-optimized composite index.
Why it is good:
- Supports common query patterns
- Improves JOIN and filtering performance
- Does not break existing objects
CREATE INDEX IDX_SALES_EMP_DATE
ON SALES_TRANSACTIONS(EMPLOYEE_ID, TXN_DATE);
7. Apply a Bad Change
This change introduces both functional and performance issues.
Problems introduced:
- Drops a critical column (breaking change)
- Replaces JOIN with correlated subquery
- Introduces N+1 query performance issue
CREATE OR REPLACE VIEW VW_EMP_DEPT_SUMMARY AS
SELECT
e.EMPLOYEE_ID,
e.EMPLOYEE_NAME,
e.SALARY,
e.HIRE_DATE,
(SELECT d.DEPARTMENT_NAME
FROM DEPARTMENTS d
WHERE d.DEPARTMENT_ID = e.DEPARTMENT_ID) AS DEPARTMENT_NAME
FROM EMPLOYEES e;
8. Run AI Diff Analysis (Claude Prompt)
Claude will re-extract schema objects and prepare them for comparison.
Read C:/oracle-db-skills/skills/devops/version-control-sql.md first, then re-extract the DDL for these objects and overwrite the files in C:/db-version-control:
- views/VW_EMP_DEPT_SUMMARY.sql
- indexes/IDX_EMP_HIRE_DATE.sql
Also check if IDX_SALES_EMP_DATE exists and write it to indexes/IDX_SALES_EMP_DATE.sql if present.
Do NOT perform any git operations. I will provide the git diff output next.
Based on the diff, give me:
1. A summary of all changes detected
2. Impact analysis
3. Classification: ADDITIVE / DESTRUCTIVE / NEUTRAL
4. Risk level: LOW / MEDIUM / HIGH
5. Recommendation: COMMIT or REVERT
Wait for my approval before any further steps.
8.1 Generate Git Diff (Manual Step)
Run the following command and paste the output into Claude:
git diff
9. Commit or Revert Based on Approval
After reviewing Claude’s analysis:
To commit:
git add .
git commit -m "schema update approved"
To revert:
git checkout -- .
Conclusion
You now have a production-ready, human-in-the-loop AI-assisted version control workflow for Oracle Database.
Claude acts as an intelligent reviewer — not an executor.
It:
- Enforces best practices automatically
- Identifies risky changes
- Explains impact clearly
- Helps you make informed decisions
This transforms database change management from a manual, error-prone process into a safe, explainable, and review-driven workflow.
In short: AI is not committing your code — it is reviewing your decisions.

No comments: