3365
MariaDBERRORNotableDDLHIGH confidence
Aggregate function not allowed in column default value
Production Risk
Low — DDL fails; table is not created or altered.
How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLE t (total INT DEFAULT (COUNT(*)));
expected output
ERROR 3365 (HY000): Aggregate functions are not allowed in DEFAULT expressions.
Fix
Use a literal default
Use a literal default
CREATE TABLE t (total INT DEFAULT 0);
Why this works
Literal values are always valid in DEFAULT clauses.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3365 ER_AGGREGATE_FUNCTION_IN_DEFAULT_VALUE
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev