SQL Error Codes
SQL Seeker's SQL Error Code Lookup is your go-to reference for decoding common error codes in databases like MySQL and PostgreSQL.
Stuck on an SQL error? Whether you're a beginner facing a syntax error or an intermediate developer troubleshooting a constraint violation, this guide lists error codes, their causes, and practical fixes to get you back on track.
SQL Error Code Reference Table
Error Code | Dialect | Description | Cause | Fix |
---|---|---|---|---|
1064 | MySQL | Syntax Error | Invalid SQL syntax, e.g., missing semicolon, incorrect keyword usage, or misplaced clause. | Check query for typos; validate syntax using MySQL docs; ensure proper semicolon; use |
1054 | MySQL | Unknown Column | Column not found in table, incorrect column name, or missing table alias. | Verify column name; check schema with |
1146 | MySQL | Table Doesn't Exist | Table not found in database, possibly due to typo, wrong database, or dropped table. | Confirm table name; ensure correct database with |
1452 | MySQL | Foreign Key Constraint Fails | Inserted value violates foreign key; referenced key missing in parent table. | Ensure referenced key exists; check constraints with |
1062 | MySQL | Duplicate Entry | Unique constraint violated, e.g., duplicate primary key or unique index. | Check for existing values with |
1048 | MySQL | Column Cannot Be Null | Non-null column received NULL value during insert or update. | Provide a valid value; alter column with |
1215 | MySQL | Cannot Add Foreign Key Constraint | Mismatch in data types, missing index, or referencing non-unique column. | Match data types; add index with |
1364 | MySQL | Field Doesn't Have Default Value | Strict mode enabled; NOT NULL column lacks default value. | Provide value; set default with |
2002 | MySQL | Can't Connect to MySQL Server | Server down, incorrect host/port, or network issues. | Verify server status; check host/port; ensure permissions with |
2013 | MySQL | Lost Connection During Query | Server timeout, network interruption, or large query execution. | Increase |
42703 | PostgreSQL | Undefined Column | Column not found in table or incorrect column name. | Verify column name; check schema with |
42P01 | PostgreSQL | Undefined Table | Table not found in database or schema; possible typo or wrong schema. | Confirm table and schema; use |
23505 | PostgreSQL | Unique Violation | Duplicate value in column with unique constraint. | Check duplicates with |
23503 | PostgreSQL | Foreign Key Violation | Inserted value violates foreign key; referenced key missing. | Ensure referenced key exists; check constraints with |
42601 | PostgreSQL | Syntax Error | Invalid SQL syntax, e.g., missing comma, incorrect keyword. | Validate syntax; use |
22003 | PostgreSQL | Numeric Value Out of Range | Value exceeds column’s numeric range or precision. | Adjust value; alter column with |
22001 | PostgreSQL | String Data Right Truncation | String value too long for column’s defined length. | Shorten string; increase length with |
28P01 | PostgreSQL | Invalid Authorization Specification | Incorrect username or password during connection. | Verify credentials; ensure user exists with |
53300 | PostgreSQL | Too Many Connections | Exceeded maximum number of database connections. | Increase |
206 | SQL Server | Invalid Column Name | Column not found in table or incorrect column name. | Verify column name; check schema with |
208 | SQL Server | Invalid Object Name | Table or view not found; possible typo or wrong database. | Confirm table name; ensure correct database with |
547 | SQL Server | Foreign Key Constraint Violation | Inserted value violates foreign key; referenced key missing. | Ensure referenced key exists; check with |
2627 | SQL Server | Unique Constraint Violation | Duplicate value in primary key or unique index. | Check duplicates with |
8152 | SQL Server | String or Binary Data Would Be Truncated | Data exceeds column’s defined length. | Shorten data; increase size with |
1205 | SQL Server | Deadlock Detected | Transaction blocked by another, causing deadlock. | Optimize queries; use |
18456 | SQL Server | Login Failed for User | Incorrect username, password, or insufficient permissions. | Verify credentials; check with |
4060 | SQL Server | Cannot Open Database | Database does not exist or user lacks access. | Verify database name; grant access with |
14 | SQLite | Unable to Open Database File | Database file not found, locked, or insufficient permissions. | Verify file path; ensure read/write permissions; check if locked by another process. |
1 | SQLite | Syntax Error | Invalid SQL syntax, e.g., missing semicolon or incorrect keyword. | Check query for typos; validate syntax using SQLite docs; ensure proper punctuation. |
19 | SQLite | Constraint Violation | Violation of primary key, unique, or foreign key constraint. | Check data for duplicates or invalid references; modify constraints with |
5 | SQLite | Database is Locked | Another process or transaction is accessing the database. | Close other connections; use |
13 | SQLite | Database Disk Image is Malformed | Corrupted database file due to improper shutdown or disk error. | Restore from backup; use |
26 | SQLite | File is Not a Database | File format not recognized as a valid SQLite database. | Verify file is a valid SQLite database; recreate database if corrupted; check file extension. |
ORA-00904 | Oracle | Invalid Identifier | Column, table, or object name not found or incorrectly specified. | Verify names; check schema with |
ORA-00942 | Oracle | Table or View Does Not Exist | Table or view not found in schema or insufficient privileges. | Confirm table name; check with |
ORA-01400 | Oracle | Cannot Insert NULL | Non-null column received NULL value during insert. | Provide a valid value; alter column with |
ORA-02291 | Oracle | Integrity Constraint Violated | Foreign key violation; referenced key missing in parent table. | Ensure referenced key exists; check constraints with |
ORA-00001 | Oracle | Unique Constraint Violated | Duplicate value in primary key or unique constraint. | Check duplicates with |
ORA-01017 | Oracle | Invalid Username/Password | Incorrect credentials or locked account. | Verify credentials; unlock account with |