in first step if you want to create a table to prevent from NULL
values and use '' as default you need to add the default attribute to that column as below:
CREATE TABLE users (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
user_name VARCHAR(30) NOT NULL DEFAULT ''
);
otherwise if you already have a table then need to take this two action:
- You may update structure of table then run update query for data.
- You have to update your data and then update the structure of table:
/* update table structure */
ALTER TABLE users MODIFY COLUMN user_name VARCHAR(255) NOT NULL DEFAULT '';
and then you can update the current NULL
values by running update query:
/* update table data */
UPDATE users SET user_name = "" WHERE user_name IS NULL
CREATE TABLE ... ( ..., column_name VARCHAR(...) DEFAULT '', ...
NULL
? Also what exactly does "have" "as value for all needed columns" mean? And what has your research about defaults shown that is relevant?