Skip to content

Latest commit

History

1,125 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SQL Scripts

GitHub starsGitHub forksLineCountCocomoLicenseMy LinkedInGitHub Last Commit

PostgreSQLMySQLMariaDBOracleAWS AthenaAWS AuroraGoogle BigQuery

CodacyCodeFactorQuality Gate StatusMaintainability RatingReliability RatingSecurity RatingVulnerabilities

CI Builds OverviewShellCheckYAMLMarkdownValidationGrypeKicsSemgrepSemgrep CloudTrivy

LinuxMacRepo on GitHubRepo on GitLabRepo on Azure DevOpsRepo on BitBucket

git.io/SQL

Useful SQL scripts, split from DevOps Bash tools, for which this is now a submodule.

Hari Sekhon

Cloud & Big Data Contractor, United Kingdom

My LinkedIn
(you're welcome to connect with me on LinkedIn)

Inventory

DevOps / DBA

  • aws_athena_cloudtrail_ddl.sql - AWS Athena DDL to setup up integration to query CloudTrail logs from Athena
  • bigquery_*.sql - Google BigQuery scripts:
    • bigquery_billing_*.sql - billing queries for GCP usage eg. highest cost services, most used GCP products, recent charges etc.
    • bigquery_info_*.sql - information schema queries for datasets, tables, columns, partitioning, clustering etc.
  • mysql_*.sql:
    • MySQL / MariaDB queries for DBA investigating + performance tuning
    • mysql_info.sql - summary overview, useful to debug your mysql.user table auth effects
      • (shows intended USER() vs actual CURRENT_USER())
    • tested on MySQL 5.5, 5.6, 5.7, 8.0 and MariaDB 5.5, 10.x
  • postgres_*.sql:
    • PostgreSQL queries for DBA investigating + performance tuning
    • postgres_info.sql - big summary overview, recommend you start here
    • tested on PostgreSQL 8.4, 9.x, 10.x, 11.x, 12.x, 13.x
  • oracle_*.sql:
    • Oracle queries for DBA investigating
    • tested on Oracle 9i, 10g, 11g, 19c

Analytics

  • bigquery_*.sql - Google BigQuery scripts:
    • bigquery_billing_*.sql - billing queries for GCP usage eg. highest cost services, most used GCP products, recent charges etc.
    • bigquery_info_*.sql - information schema queries for datasets, tables, columns, partitioning, clustering etc.
    • analytics/bigquery_*.sql - ecommerce queries and BigQuery ML machine learning classification logistic regression models and purchasing predictions
    • for more BigQuery examples, see Data Engineering demos

Database Knowledge Base

See the pages for:

in the HariSekhon/Knowledge-Base repo:

Readme Card

DevOps SQL tooling

Readme Card

You can quickly test the PostgreSQL / MySQL scripts using postgres.sh / mysqld.sh / mariadb.sh in the DevOps Bash tools repo, which boots a docker container and drops straight in to a mysql / psql shell with this directory mounted at /sql and used as $PWD for fast easy sourcing eg.

postgres:

\i /sql/postgres_query_times.sql
\i postgres_query_times.sql

mysql:

source /sql/mysql_sessions.sql
\. mysql_sessions.sql

Related scripts

Star History

Star History Chart

git.io/SQL

More Core Repos

Knowledge

Knowledge-BaseDiagrams-as-Code

DevOps Code

DevOps-Bash-toolsDevOps-Python-toolsDevOps-Perl-toolsDevOps-Golang-tools

Containerization

Kubernetes-configsDockerfiles

CI/CD

GitHub-ActionsJenkins

Databases - DBA - SQL

SQL-scripts

DevOps Reloaded

HAProxy-configsTerraformPackerAnsibleEnvironments

Monitoring

Nagios-PluginsNagios-Plugin-KafkaPrometheus

Templates

TemplatesTemplate-repo

Desktop

TamperMonkeyHammerspoonMPV-Scripts

Spotify

Spotify-toolsSpotify-playlists

The rest of my original source repos are here.

Pre-built Docker images are available on my DockerHub and can be re-generated using the my Dockerfiles repo.

About

100+ SQL Scripts - PostgreSQL, MySQL, Oracle, Google BigQuery, MariaDB, AWS Athena. DBA, Analytics, DevOps, performance engineering. Google BigQuery ML machine learning classification.

Topics

Resources

Stars

487 stars

Watchers

17 watching

Forks

Contributors

Languages