A collection of SQL scripts for database administration across Oracle, PostgreSQL, MySQL, and SQL Server.
A personal toolbelt of diagnostic and maintenance scripts for day-to-day DBA work. Scripts are production-tested and organized by database platform. Includes both quick-reference scripts and a complete monitoring database for SQL Server.
| Platform | Scripts | Status |
|---|---|---|
| Oracle | 8 | Active |
| PostgreSQL | 8 | Active |
| MySQL | 6 | Active |
| SQL Server | 21 | Active |
Each script runs independently - just open in your database client and execute.
Oracle
oracle/sessions_active.sql- Current session inventoryoracle/tablespace_check.sql- Tablespace utilization with alertsoracle/blocking_sessions.sql- Lock contention analysis
PostgreSQL
postgres/sessions_current.sql- Active connectionspostgres/locks_blocking.sql- Lock wait chainspostgres/bloat_check.sql- Table bloat detection
MySQL
mysql/sessions.sql- Thread inventorymysql/innodb_status.sql- Buffer pool metricsmysql/slow_queries.sql- Query performance analysis
SQL Server
sqlserver/active_sessions.sql- SPID inventorysqlserver/wait_stats.sql- Wait type statisticssqlserver/blocking_chains.sql- Blocking session tree
A complete monitoring and maintenance database for SQL Server. Includes:
- Performance monitoring (waits, perf counters, query stats)
- Backup tracking
- Security auditing (login attempts, role changes)
- Index maintenance logging
- Alert framework
- Growth projections
- AG/replica health monitoring
Installation:
# Run scripts in order:
# 1. 00_create_database.sql
# 2. 01_tables.sql
# 3. 02_procedures.sql
# ... continue through 16_baseline_comparison.sqlSee sqlserver/dbatools/readme.md for details.
- Oracle 11g+ (for Oracle scripts)
- PostgreSQL 12+ (for PostgreSQL scripts)
- MySQL 5.7+ (for MySQL scripts)
- SQL Server 2016+ (for SQL Server scripts)
- Appropriate database privileges (DBA role, sysadmin, etc.)
MIT License - free to use, just credit the author.
Author: Andrew Reischl | GitHub: https://github.com/Thalionn/db-scripts