Disallow empty values for a column in MySQL
To avoid a NULL value in a table column in MySQL we specify NOT NULL constraint when you create a table. But NOT NULL constraint still allows empty values.
To avoid empty values while inserting a record we can have a check in the table DDL itself.
`store_id` varchar(20) NOT NULL CHECK (store_id <> ''),
When you try to insert a record with store_id as an empty string, you would get the following error.
CONSTRAINT `store_orders.store_id` failed for `storeapp`.`store_orders`