All rules

Safety

postgresql/no-identifier-too-long

Disallow identifiers longer than PostgreSQL's `NAMEDATALEN - 1` limit (default 63 bytes).

  • Type problem
  • Recommended error
  • Fixable no

Why this matters

PostgreSQL stores identifiers in a fixed-width `name` column whose size is `NAMEDATALEN` (64 by default). Anything longer than `NAMEDATALEN - 1` bytes is **silently truncated** at parse time, so the object is created under a different name than written. Every later `DROP CONSTRAINT` / `ALTER ... RENAME` / `\d` that uses the original name then fails with `does not exist`. Bytes — not characters — count, so a 22-character CJK name is already over the limit.

Examples

Incorrect

Incorrect
CREATE TABLE this_is_a_very_very_very_very_very_very_very_very_long_table (id bigserial PRIMARY KEY);
Incorrect
ALTER TABLE items
  ADD CONSTRAINT items_code_check_that_is_unfortunately_far_too_long_for_postgresql CHECK (length(code) > 0);
Incorrect
CREATE INDEX an_index_name_that_exceeds_the_sixty_three_byte_postgres_limit ON items (code);

Correct

Correct
CREATE TABLE long_but_within_limit_table (id bigserial PRIMARY KEY);
Correct
ALTER TABLE items ADD CONSTRAINT items_code_non_empty CHECK (length(code) > 0);
Correct
CREATE INDEX items_code_idx ON items (code);

Configure it

// eslint.config.js
import postgresql from "eslint-plugin-postgresql";

export default [
  {
    files: ["**/*.sql"],
    languageOptions: {
      parser: postgresql.configs.recommended.languageOptions.parser,
    },
    plugins: { postgresql },
    rules: {
      "postgresql/no-identifier-too-long": [
        "error",
        {
          max: 63,
        },
      ],
    },
  },
];

Options

max integer default: 63
Maximum identifier byte length. Override only if your PostgreSQL build raises `NAMEDATALEN` from the default 64.
Try this rule

Edit the SQL — only no-identifier-too-long is enabled.

Pre-filled with the first incorrect example. Toggle off in the rule shelf to see how the diagnostic disappears.

0 errors 0 warnings parse 0ms · rules 0ms
Diagnostics

No issues found.

2 rules enabled.

Rule under test no-identifier-too-long — plus no-syntax-error as a safety net.
eslint-plugin-postgresql

An ESLint plugin that lints .sql files with real PostgreSQL grammar and a curated set of best-practice rules.

© 2026 eslint-plugin-postgresql contributors Built on libpg-query · PostgreSQL 17