Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

E0001 table-not-found

Referenced table does not exist in schema.

CodeNameCategoryDefault
E0001table-not-foundcorrectnesserror

What it reports

A query refers to a table or view that isn't defined in the schema, and isn't a CTE or a table created earlier in the same file.

Example

SELECT * FROM user;
error[E0001]: Table 'user' not found
  --> q.sql:1:15
    |
  1 | SELECT * FROM user;
    |               ^^^^
    = help: Did you mean 'users'?

Fixed:

SELECT * FROM users;

Notes

  • Typos in a table name. sqlsift suggests the closest existing name.
  • A table that was renamed or dropped by a later migration. The help names the schema file and line of the ALTER TABLE ... RENAME TO or DROP TABLE ('people' was renamed to 'persons' in db/migrations/0005_rename_people.sql:2), or the line of the query file when the change is in the query file itself ('tmp' was dropped at line 3 of this file).
  • A table created in a migration that sqlsift didn't load. Run sqlsift schema to see what was loaded, and check the order of files in --schema-dir.
  • Qualifying a column with a table's name after giving the table an alias (SELECT users.id FROM users u). Once aliased, the table must be referred to by its alias: Table or alias 'users' not found in FROM clause.

Configuring

# sqlsift.toml
[rules]
table-not-found = "warn"   # or "off"

Or for a single line: -- sqlsift:disable E0001. The examples use the schema on the Rules page.