Scripts Gallery
Ready-made BroadSQL Scripts to download into your Scripts Library: a first collection of diagnostics, data checks and a reconciliation routine. Each one has a complete metadata header (description, dialect, access, typed parameters), so LIB SHOW explains it, LIB LINT checks it, and LIB FIND finds it again.
Each page states how far its Script was verified. Only the WORLD sample Scripts show output captured from a real run; the others are written from the BroadSQL documentation and the vendor's documentation, and were not run by the BroadSQL team. Run a Script on a test database first, and read its result critically.
Largest countries of a continentA first Script to learn from: a required text parameter, an optional integer with a default, on the WORLD sample of every installation.
Countries by ISO codeA list parameter in practice: pass several codes at once, each sent to the database as its own typed value.
Largest cities of a list of countriesA join of two tables of the WORLD sample with a list parameter and a default threshold.
Estimated row count of every table (PostgreSQL)Row counts of every table of a schema, read from PostgreSQL's statistics instead of counting each table.
Largest tables on disk (PostgreSQL)The tables that take the most disk space, indexes and TOAST data included.
Blocked and blocking sessions (PostgreSQL)During an incident: which sessions wait for a lock, and which sessions hold it.
Long-running queries (PostgreSQL)The queries running for longer than a number of seconds, your own session excluded.
Largest tables on disk (SQL Server)The tables of the current database that reserve the most space, with their approximate row count.
Blocked requests (SQL Server)During an incident: the requests waiting on another session, with what they wait for and their query.
Duplicate values in a column (template, runs on WORLD)A data quality check to run on WORLD, then adapt: the values of a column that should be unique but appear several times. On WORLD, the names shared by several cities.
Rows changed since a time (template, runs on WORLD)A check to run on WORLD, then adapt: the rows modified at or after a given time, for a table with a modification timestamp. On WORLD, the countries changed since a date.
Rows missing between two databases (template, WORLD and WORLD-QA)A reconciliation routine: copy a table from two connections into one local H2 database, then count the rows found on one side only. Written for the practice connections WORLD and WORLD-QA.
Use a Script from the gallery
- Download the file and save it in your Scripts Library (the
scriptsfolder of your installation), for example in agallerysubfolder. LIB SHOW gallery/<file>;shows its parameters, access and dialect;LIB LINT gallery/<file>;checks it.- Run it with
@gallery/<file> name=value ..., or export its result withDUMP LIB gallery/<file> TO ... AS ...;. - Adapt it: Scripts are plain text files. The templates name the table and the columns to replace.
Related
- Save a query and run it by name
- Script directives: every header line.
- Scripts Library
Found something wrong or unclear on this page? Tell us, with the page address.