🗃️ SQL errors

Database-agnostic SQL errors: syntax, constraints, deadlocks and connection issues.

CodeErrorWhat it means
GROUP BY Column must appear in the GROUP BY clause / isn't in GROUP BY (MySQL 1055 only_full_group_by) You selected a column that is neither grouped nor aggregated, so the result would be ambiguous.
ambiguous column Column reference is ambiguous / Column 'id' in field list is ambiguous (MySQL 1052) A column name exists in more than one joined table, so the database doesn’t know which one you mean.
Deadlock Deadlock found when trying to get lock; try restarting transaction Two transactions waited on each other’s locks; the database killed one so the other could continue.
aggregate in WHERE ERROR: aggregate functions are not allowed in WHERE (use HAVING) / MySQL 1111 Invalid use of group function An aggregate (SUM, COUNT, AVG) was used in WHERE, which filters rows before grouping.
window in WHERE ERROR: window functions are not allowed in WHERE A window function (ROW_NUMBER, RANK, LAG) was filtered directly in WHERE.
Lock wait timeout Lock wait timeout exceeded; try restarting transaction (MySQL 1205) A query waited too long for a row lock held by another transaction and gave up.
recursion limit Msg 530: The statement terminated. The maximum recursion 100 has been exhausted before statement completion. / MySQL 3636 Recursive query aborted after 1001 iterations A recursive CTE exceeded the database’s recursion limit — often an infinite loop in hierarchical data.
1066 MySQL ERROR 1066 (42000): Not unique table/alias: 'x' The same table or alias appears twice in a FROM/JOIN without distinct aliases.
1136 MySQL ERROR 1136 (21S01): Column count doesn't match value count at row 1 An INSERT supplies a different number of values than columns.
1222 MySQL ERROR 1222 (21000): The used SELECT statements have a different number of columns The SELECTs combined with UNION return different numbers of columns.
1248 MySQL ERROR 1248 (42000): Every derived table must have its own alias A subquery in FROM wasn’t given an alias.
1267 MySQL ERROR 1267 (HY000): Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '=' Two strings with different collations were compared or joined.
ORA-00001 ORA-00001: unique constraint (SCHEMA.PK_X) violated An insert/update duplicated a value in a unique or primary key constraint.
ORA-00054 ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired DDL or a NOWAIT lock couldn’t get the lock because another session holds it.
ORA-00904 ORA-00904: "X": invalid identifier A column name in the statement doesn’t exist (or is misquoted).
ORA-00933 ORA-00933: SQL command not properly ended Oracle found extra clauses or syntax it doesn’t support at the end of a statement.
ORA-00942 ORA-00942: table or view does not exist Oracle can’t see the table — it doesn’t exist, is in another schema, or you lack privileges on it.
ORA-01017 ORA-01017: invalid username/password; logon denied Oracle rejected the credentials.
ORA-01400 ORA-01400: cannot insert NULL into ("SCHEMA"."TABLE"."COLUMN") A NULL was inserted into a NOT NULL column.
ORA-01722 ORA-01722: invalid number Oracle tried to convert a string to a number and failed.
ORA-06512 ORA-06512: at "SCHEMA.PROC", line N A stack-trace line from PL/SQL — the real error is the ORA- code above it.
ORA-12154 ORA-12154: TNS:could not resolve the connect identifier specified The Oracle client couldn’t find the alias in tnsnames.ora (or the naming method can’t resolve it).
ORA-12505 ORA-12505: TNS:listener does not currently know of SID given in connect descriptor The connect string uses a SID the listener doesn’t know — often a service name passed as SID.
ORA-12514 ORA-12514: TNS:listener does not currently know of service requested in connect descriptor The listener is up but doesn’t know the service name you requested.
ORA-12541 ORA-12541: TNS:no listener Nothing listens on the Oracle host/port — the listener is down or you have the wrong port.
N+1 queries Performance: N+1 query problem (one query per row in a loop) Code runs one query to load a list, then one more query per item — hundreds of queries per page.
Division by zero SQL Error: division by zero / Divide by zero error encountered An expression divided by a value that was 0 for at least one row.
Network-related error SQL Server: A network-related or instance-specific error occurred while establishing a connection to SQL Server. (provider: Named Pipes Provider, error: 40 / TCP Provider, error: 26) The client couldn’t reach the SQL Server instance — wrong server name/instance, TCP disabled, firewall, or SQ…
8115 SQL Server: Arithmetic overflow error converting expression to data type int. (Msg 8115) A value or calculation exceeds the target data type’s range.
544 SQL Server: Cannot insert explicit value for identity column in table 'x' when IDENTITY_INSERT is set to OFF. An INSERT supplied a value for an IDENTITY column.
245 SQL Server: Conversion failed when converting the varchar value 'x' to data type int. (Msg 245) SQL Server tried to convert text to a number (often implicitly) and hit a non-numeric value.
Execution Timeout Expired SQL Server: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The command ran longer than the client’s CommandTimeout (default 30 seconds).
102 SQL Server: Incorrect syntax near 'x'. (Msg 102) T-SQL couldn’t parse the statement near the shown token.
207 SQL Server: Invalid column name 'x'. (Msg 207) SQL Server can’t find the column — typo, missing migration, or a string in double quotes with QUOTED_IDENTIFI…
208 SQL Server: Invalid object name 'x'. (Msg 208) The table/view doesn’t exist in the current database or schema.
18456 SQL Server: Login failed for user 'x'. (Error 18456) SQL Server rejected the login — wrong password, wrong authentication mode, or a disabled/missing login.
8152 / 2628 SQL Server: String or binary data would be truncated in table 'x', column 'y'. (Msg 2628) A value is longer than the column allows.
certificate chain not trusted SQL Server: The certificate chain was issued by an authority that is not trusted. The client requires an encrypted connection and doesn’t trust SQL Server’s (often self-signed) certificate.
547 SQL Server: The INSERT statement conflicted with the FOREIGN KEY constraint 'x'. (Msg 547) The row references a parent that doesn’t exist (or a DELETE would orphan children).
2627 SQL Server: Violation of PRIMARY KEY constraint 'x'. Cannot insert duplicate key in object 'y'. (Msg 2627) An insert duplicated a primary key or unique constraint value.
malformed database sqlite3.DatabaseError: database disk image is malformed The SQLite file is corrupted.
SQLite FK failed sqlite3.IntegrityError: FOREIGN KEY constraint failed An insert/update/delete violated a foreign key in SQLite (with PRAGMA foreign_keys=ON).
SQLite NOT NULL failed sqlite3.IntegrityError: NOT NULL constraint failed: table.column A NULL went into a NOT NULL column in SQLite.
SQLite UNIQUE failed sqlite3.IntegrityError: UNIQUE constraint failed: users.email An insert/update duplicated a value in a UNIQUE or PRIMARY KEY column in SQLite.
readonly database sqlite3.OperationalError: attempt to write a readonly database The process can’t write to the SQLite file or its directory.
SQLITE_BUSY sqlite3.OperationalError: database is locked (SQLITE_BUSY) Another connection holds a write lock on the SQLite file, and this one gave up waiting.
SQLite syntax error sqlite3.OperationalError: near "x": syntax error SQLite couldn’t parse the statement; the token after “near” is where it stopped.
SQLite no such column sqlite3.OperationalError: no such column: x SQLite can’t find the column — missing migration, typo, or a string written in double quotes.
unable to open database sqlite3.OperationalError: unable to open database file SQLite couldn’t open or create the database file — wrong path or missing/unwritable directory.
Subquery returns more than 1 row Subquery returns more than 1 row (MySQL 1242) / more than one row returned by a subquery used as an expression A subquery used where a single value is expected (`= (SELECT …)`) returned several rows.
pool timeout Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. All pooled connections were in use and max pool size was reached. The application’s connection pool was exhausted — all connections busy or leaked.