A curated collection of practical SQL scripts, administration snippets, and reusable database utilities for SQL Server, PostgreSQL, MySQL, Oracle, and DB2.
This repository focuses on real-world database work: metadata discovery, data quality checks, missing-number analysis, index maintenance, partitioning, search-and-replace operations, geocoding helpers, and security-oriented logon restrictions.
- Centralize useful scripts gathered from day-to-day database work.
- Share repeatable solutions across multiple database engines.
- Keep public examples clean, documented, and safe to reuse.
| Engine | Files | Typical Topics |
|---|---|---|
| MS SQL Server | 33 | metadata, automation, partitioning, geocoding, security triggers, maintenance |
| PostgreSQL | 5 | dblink, metadata, missing records, role grants |
| Oracle | 3 | server/session metadata, table comments, column discovery |
| MySQL | 2 | index discovery and index maintenance procedures |
| DB2 | 1 | connection and administration command cheatsheet |
.
|-- DB2/
|-- MS SQL Server/
|-- MySQL/
|-- Oracle/
`-- PostgreSQL/
- Address validation and geocoding helpers.
- Metadata exploration for tables, views, functions, and dependencies.
- Partition creation and partition maintenance examples.
- Search-and-replace utilities and text formatting helpers.
- Security samples for host, application, and IP-based restrictions.
- Querying remote sources with
dblink. - Finding and remediating missing sequence-style values.
- Listing tables across schemas with descriptions.
- Granting reporting access with reusable privilege templates.
- Inspecting server host information for the current session.
- Listing tables that contain a specific column pattern.
- Reviewing table and column comments for documentation work.
- Generating missing index statements.
- Rebuilding indexes for all base tables in a database.
- Connecting, attaching, listing objects, and handling backup/restore tasks.
- Review each script before running it in shared or production environments.
- Replace all placeholder values such as
<DB2_USER>,<REMOTE_HOST>, or[YourDatabaseName]. - Keep credentials, API keys, internal hostnames, and IP addresses outside source control.
- Test maintenance, partitioning, and logon-trigger scripts in non-production first.
- Adapt object names, schemas, and thresholds to your environment before execution.
- Public samples use placeholders instead of real passwords, hosts, or blocked IP addresses.
- Environment-specific database references have been generalized where possible.
- Scripts are being normalized with clearer comments and safer customization points.
If you contribute new examples, do not commit:
- passwords or tokens
- internal server names
- private IP addresses
- customer-specific connection strings
- Place new scripts in the correct engine folder.
- Add a short header comment describing purpose, prerequisites, and what must be customized.
- Prefer portable examples over environment-specific copies.
- Keep formatting clean so scripts are easy to scan and adapt.
- Expand coverage for performance diagnostics and observability.
- Continue standardizing file headers and placeholder conventions.
- Add more script descriptions and usage examples over time.