Error Reference › SQL / Database
SQL / Database
Table doesn't exist (1146)
The query references a table the database can't find.
What it looks like
ERROR 1146 (42S02): Table 'shop.orders' doesn't exist
What does "Table doesn't exist (1146)" mean?
Returned by MySQL when a query names a table it cannot find. The message shows database.table, so it tells you both the table name and the database the connection is actually using.
What causes "Table doesn't exist (1146)"?
- Typo or wrong case in the table name.
- Wrong database/schema selected.
- Migrations not run.
How do I confirm the cause?
- Compare the database name in the message with the one you expected — the connection may point at the wrong database.
- Run SHOW TABLES in that database and check the exact spelling and case (on Linux, table names are case-sensitive by default).
- Check whether the migration that creates the table has been run in this environment.
- In tests or CI, check the test database was created and migrated — test suites often point at a separate, empty database.
How do I fix "Table doesn't exist (1146)"?
- Check the exact table name and case.
- Confirm you're connected to the right database/schema.
- Run pending migrations.
How do I stop it happening again?
- Run migrations automatically as part of every deploy.
- Use one consistent case for table names, ideally all lowercase.
- Refer to tables through your ORM or a single place in the code rather than retyping names in raw SQL, so a rename cannot miss one.