Relative Content

Tag Archive for mysqlpostgresqldefault-valuenotnull

Is there a way to set default values of columns that are NOT NULL in postgres?

In PostgreSQL, when a column is marked as NOT NULL and no value is provided for it during insertion, an error is thrown. However, in MySQL, if no value is provided, the default value is set based on the column’s type, such as '' for string values, 0 for integers, 0.00 for floats(scale: 2), etc. It’s important to note that even in MySQL, this behavior occurs irrespective of whether a default value is explicitly mentioned.