1146ERRORTier 1 — Safe✅ HIGH confidenceTable doesn't exist
What this means
Error 1146 (SQLSTATE 42S02) is returned when a DML query (SELECT, INSERT, UPDATE, DELETE) references a table that does not exist in the current database. It is typically caused by a missing migration, a typo, or deploying application code before the corresponding database migration.
Why it happens
- 1A schema migration was not run before deploying application code that references the new table
- 2Typo in the table name in the query
- 3The application is connected to the wrong database (test vs. production)
- 4The table was accidentally dropped
How to reproduce
A SELECT references a table that was never created.
SELECT * FROM user_sessions; -- table doesn't existFix 1: Run the missing migration
When the table should exist but was never created.
CREATE TABLE user_sessions (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
user_id INT NOT NULL,
token VARCHAR(255) NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);Why this works
Creating the table makes it available for DML queries. In a deployment workflow, ensure migrations are applied before the application starts.
Fix 2: Verify available tables
When troubleshooting what tables actually exist.
SHOW TABLES;
-- or:
SELECT TABLE_NAME FROM information_schema.TABLES
WHERE TABLE_SCHEMA = DATABASE();Why this works
SHOW TABLES lists all tables in the current database, allowing the exact name to be confirmed.
What not to do
Create the table manually in production outside the migration system
Why it's wrong: Manually created tables diverge from the tracked migration state, causing future migrations to fail and making environment parity impossible.
Version notes
All versionsStable error code.Sources
📚 Official docs: https://mariadb.com/kb/en/show-tables/
🔧 Source ref: MariaDB Server error code 1146 / ER_NO_SUCH_TABLE
📖 Further reading: MariaDB SHOW TABLES
Confidence assessment
✅ HIGH confidence
Stable.
See also
🔗 Related errors
📄 Reference pages