Is there a way, via a SQL statement, to ensure a column's default value is an empty string ''
instead of NULL
?
In Object Explorer, right-click the table with columns for which you want to change the scale and select Design. Select the column for which you want to specify a default value. In the Column Properties tab, enter the new default value in the Default Value or Binding property.
You cannot alter a column to specify a default value if one of the following conditions exists: The table is referenced by a view.
Certain columns and data types have predefined or assigned default values. For example, default column values for the various data types are as follows: NULL. 0 Used for small integer, integer, decimal, single-precision floating point, double-precision floating point, and decimal floating point data type.
Default values can be NULL, or they can be a value that matches the data type of the column (number, text, date, for example).
Yes - use a DEFAULT constraint:
DROP TABLE IF EXISTS `example`.`test`; CREATE TABLE `example`.`test` ( `string_test` varchar(45) NOT NULL DEFAULT '' ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With