I have MySQL table with the following structure:
-------------
| id | name |
-------------
Where ID is int auto_increment and name is just varchar(255).
So I need to set using database default value for the name (if it's empty after insert request) like:
INSERT INTO users;
id = 1
name = "User1"
... it should also work with null:
INSERT INTO users (name) VALUES (null);
id=8232
name = "User8232"
and also it would be nice if we send empty value for name:
INSERT INTO users (name) VALUES ('');
id=8233
name = "User8233"
But if I explicitly set value that should be:
INSERT INTO users VALUES ('TestUser')
id=8232
name = "TestUser"
Also, it would be nice if that logic would be not in the trigger but in the table definition or in the insert query itself.
So the purpose of that making unique User name for new registrations.
Thank you!