89 rules, each with a single concern.
Filter by severity, kind, or category. Click any rule for the full rationale, examples and a per-rule playground seeded with the failing SQL.
no-syntax-error
error problemDetect PostgreSQL syntax errors.
Syntax Readno-select-star
off suggestionDisallow `SELECT *` (and `<alias>.*`) so result schemas stay stable.
Style Readrequire-where-in-delete
error problemRequire a WHERE clause on DELETE.
Safety Readrequire-where-in-update
error problemRequire a WHERE clause on UPDATE.
Safety Readno-drop-table-cascade
warn problemWarn on DROP TABLE ... CASCADE.
Safety Readno-truncate-cascade
warn problemWarn on TRUNCATE ... CASCADE.
Safety Readno-cross-join
warn suggestionWarn on CROSS JOIN.
Safety Readno-natural-join
error problemDisallow NATURAL JOIN — join columns are implicit.
Safety Readconsistent-jsonb-over-json
warn suggestionEnforce a consistent stance on `jsonb` vs `json` for column types.
Schema Readconsistent-identity-over-serial
warn suggestionEnforce a consistent stance on `GENERATED ... AS IDENTITY` vs `SERIAL` / `BIGSERIAL`.
Schema Readrequire-primary-key
warn suggestionRequire a primary key on CREATE TABLE.
Schema Readconsistent-text-over-varchar
warn suggestionEnforce a consistent stance on `text` vs `varchar(n)`.
Schema Readconsistent-timestamptz
warn suggestionEnforce a consistent stance on `timestamptz` vs `timestamp` for wall-clock columns.
Schema Readno-money-type
error problemForbid the money column type.
Schema Readno-char-type
warn suggestionAvoid CHAR(n) — it pads on write and trims on read.
Schema Readno-grant-to-public
warn problemAvoid GRANT ... TO PUBLIC.
Security Readconsistent-create-index-concurrently
off suggestionEnforce a consistent stance on `CONCURRENTLY` for `CREATE INDEX`.
Performance Readno-not-in-subquery
error problemDisallow NOT IN (subquery) — NULL handling is a trap.
Safety Readsnake-case-table-name
warn suggestionRequire snake_case table names.
Style Readsnake-case-column-name
warn suggestionRequire snake_case column names.
Style Readno-implicit-join
warn suggestionAvoid implicit (comma) joins.
Style Readrequire-limit
warn suggestionRequire a LIMIT clause on SELECT.
Performance Readno-order-by-ordinal
warn suggestionDisallow positional `ORDER BY` references (e.g., `ORDER BY 1`).
Style Readno-group-by-ordinal
warn suggestionDisallow positional `GROUP BY` references (e.g., `GROUP BY 1`).
Style Readno-distinct-on-without-order-by
error problemRequire ORDER BY alongside `SELECT DISTINCT ON (...)` so the surviving row is deterministic.
Safety Readno-leading-wildcard-like
warn suggestionWarn on `LIKE`/`ILIKE` patterns that begin with `%`; they force sequential scans.
Performance Readno-add-column-not-null-without-default
error problemError on `ADD COLUMN ... NOT NULL` without a `DEFAULT` — fails on non-empty tables.
Safety Readno-select-into
warn suggestionDisallow `SELECT ... INTO target FROM ...`; prefer `CREATE TABLE AS SELECT`.
Style Readprefer-coalesce-over-case
warn suggestionFlag `CASE WHEN x IS NULL THEN y ELSE x END` and recommend `COALESCE(x, y)`.
Style Readno-having-without-group-by
error problemDisallow `HAVING` without `GROUP BY`; the predicate belongs in `WHERE`.
Safety Readno-identifier-too-long
error problemDisallow identifiers longer than PostgreSQL's `NAMEDATALEN - 1` limit (default 63 bytes).
Safety Readno-alter-column-type
warn problemWarn on `ALTER COLUMN ... TYPE` — can rewrite the table under ACCESS EXCLUSIVE.
Safety Readno-rename-column
warn problemWarn on `RENAME COLUMN` — breaks deployed code reading the old name.
Safety Readno-rename-table
warn problemWarn on `RENAME TO` — breaks deployed code reading the old name.
Safety Readno-drop-column
warn problemWarn on `DROP COLUMN` — breaks every reader still referencing the column.
Safety Readno-drop-not-null
warn suggestionWarn on `DROP NOT NULL` — surprises consumers that already assume non-null.
Safety Readconsistent-fk-not-valid
warn problemEnforce a consistent stance on `NOT VALID` for `ALTER TABLE ... ADD FOREIGN KEY`.
Safety Readrequire-named-constraint
warn suggestionRequire explicit names on CHECK / UNIQUE / FK / EXCLUSION constraints.
Schema Readno-unlogged-table
warn problemWarn on `CREATE UNLOGGED TABLE` — data is lost on crash and not replicated.
Safety Readno-temporary-table
warn suggestionWarn on `CREATE TEMP / TEMPORARY TABLE` in versioned SQL.
Safety Readno-numeric-without-precision
warn suggestionRequire an explicit precision and scale on `NUMERIC` / `DECIMAL` columns.
Schema Readno-time-type
warn suggestionDisallow `TIME` / `TIMETZ` columns; they rarely model real values correctly.
Schema Readno-set-not-null
warn problemWarn on `SET NOT NULL` — full scan under ACCESS EXCLUSIVE.
Safety Readno-set-search-path
warn suggestionDisallow `SET search_path` in versioned SQL; qualify identifiers instead.
Safety Readrequire-schema-qualified-table
off suggestionRequire schema-qualified `CREATE TABLE` (off by default).
Schema Readprefer-explicit-null-ordering
warn suggestionRequire `NULLS FIRST/LAST` when an explicit ORDER BY direction is used.
Style Readno-vacuum-full
warn problemWarn on `VACUUM FULL` — takes ACCESS EXCLUSIVE and rewrites the table.
Safety Readno-cluster
warn problemWarn on `CLUSTER` — ACCESS EXCLUSIVE lock, and PG doesn't maintain the order.
Safety Readno-composite-primary-key
off problemDisallow composite (multi-column) PRIMARY KEY constraints.
Schema Readno-drop-database
error problemError on `DROP DATABASE` — catastrophic and belongs to an operator workflow.
Safety Readno-drop-schema-cascade
warn problemWarn on `DROP SCHEMA ... CASCADE` — removes every object in the schema with no preview.
Safety Readconsistent-reindex-concurrently
warn problemEnforce a consistent stance on `CONCURRENTLY` for `REINDEX`.
Performance Readno-create-role
warn suggestionDisallow `CREATE ROLE` / `CREATE USER` in versioned SQL.
Security Readprefer-bigint-id
warn suggestionPrefer `bigint` for primary-key `id` columns; `int` overflows at 2.1B rows.
Schema Readalign-column-definitions
off layoutAlign column definitions vertically inside `CREATE TABLE`.
Style Readalign-values
off layoutAlign column values vertically inside multi-row `INSERT ... VALUES`.
Style Readno-equality-with-null
error problemDisallow `x = NULL` / `x <> NULL`; use `IS NULL` / `IS NOT NULL`.
Safety Readno-on-delete-cascade
warn suggestionDisallow `ON DELETE CASCADE` on foreign keys.
Safety Readno-rule
warn suggestionDisallow `CREATE RULE`; it is effectively deprecated in favor of triggers and updatable views.
Safety Readno-security-definer-without-search-path
error problemDisallow `SECURITY DEFINER` functions without an explicit `SET search_path`.
Security Readno-unnecessary-quoted-identifier
off suggestionDisallow `"..."` around identifiers that don't need quoting.
Style Readno-update-primary-key
error problemDisallow `UPDATE` on primary-key columns (heuristic).
Safety Readno-update-without-from-binding
error problemDisallow `UPDATE ... FROM` without a `WHERE` (Cartesian product).
Safety Readno-with-recursive-without-limit
error problemDisallow `WITH RECURSIVE` without an outer `LIMIT`.
Safety Readplpgsql-keyword-case
off layoutEnforce a consistent case for SQL/PL/pgSQL keywords inside PL/pgSQL bodies.
Style Readprefer-add-constraint-not-valid
warn suggestionPrefer `ADD CONSTRAINT ... NOT VALID` then `VALIDATE CONSTRAINT`.
Safety Readconsistent-as-for-column-alias
off layoutEnforce a consistent stance on the `AS` keyword before column aliases in `SELECT`.
Style Readconsistent-as-for-table-alias
off layoutEnforce a consistent stance on the `AS` keyword before table aliases.
Style Readconsistent-between-over-and
off suggestionEnforce a consistent stance on `x BETWEEN a AND b` vs `x >= a AND x <= b`.
Style Readprefer-cast-operator
off layoutEnforce a single style for type casts (`x::int` or `CAST(x AS int)`).
Style Readconsistent-create-or-replace
off suggestionEnforce a consistent stance on `CREATE OR REPLACE` for `FUNCTION` / `PROCEDURE` / `VIEW`.
Safety Readprefer-current-timestamp-over-now
off layoutPrefer SQL-standard `CURRENT_TIMESTAMP` over `now()` / `LOCALTIMESTAMP`.
Style Readconsistent-drop-index-concurrently
off suggestionEnforce a consistent stance on `CONCURRENTLY` for `DROP INDEX`.
Safety Readconsistent-explicit-inner-join
off layoutEnforce a consistent stance on the explicit `INNER` keyword in `INNER JOIN`.
Style Readconsistent-explicit-outer-join
off layoutEnforce a consistent stance on the explicit `OUTER` keyword in `LEFT/RIGHT/FULL OUTER JOIN`.
Style Readprefer-in-list-over-or
off suggestionPrefer `x IN (a, b, c)` over `x = a OR x = b OR x = c`.
Style Readprefer-keyword-case
off layoutEnforce a consistent case (upper or lower) for SQL keywords.
Style Readprefer-not-equals-operator
off layoutEnforce a single style for the not-equal operator (`<>` or `!=`).
Style Readrequire-if-exists
off suggestionRequire `IF EXISTS` on every `DROP` statement.
Safety Readrequire-on-delete-action
warn suggestionRequire an explicit `ON DELETE` clause on every foreign-key constraint.
Safety Readrequire-trailing-semicolon
off layoutRequire a trailing `;` after every top-level SQL statement.
Style Readno-add-check-constraint-without-not-valid
error problemDisallow `ADD CONSTRAINT CHECK` without `NOT VALID` (lock-heavy).
Safety Readno-add-unique-constraint-directly
error problemDisallow inline `ADD CONSTRAINT UNIQUE`; require `USING INDEX`.
Safety Readno-volatile-default-on-add-column
error problemDisallow `ADD COLUMN ... DEFAULT <volatile>()` (forces full table rewrite).
Safety Readno-grant-all
warn suggestionDisallow `GRANT ALL` (list privileges explicitly).
Security Readprefer-exists-over-in-subquery
warn suggestionPrefer `EXISTS (subquery)` over `column IN (subquery)`.
Performance Readrequire-fk-include-columns
off problemRequire every foreign-key constraint to include a configured set of columns.
Schema Readrequire-table-columns
off problemRequire every `CREATE TABLE` to include a configured set of columns.
Schema Readrequire-index-on-fk-column
warn problemRequire an index on every foreign-key column.
Performance Read