I'm trying to make a couple of columns in my table set as "NOT NULL" my create goes something like this
create table if not exists tribe(
tribe _id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
language VARCHAR(20) NOT NULL,
......................so on and so on
however, when i create the table, i'm still able to insert rows with no data in the NOT NULL language. so if someone forgets to insert a language in the form, it still writes a blank cell in the database.
if i DESC the table it looks like this:
FIELD TYPE NULL KEY DEFAULT EXTRA
tribe_id int(11) PRI NULL auto_increment
people varchar(20) YES NULL
region varchar(20) YES NULL
I can see that they are blank in the NULL column but for TRIBE_ID, it's default is NULL and for language there is no default.
I just want to make it so it won't write a row in the database if the user didn't enter anything for language.
My guess is that you've got an empty string, not a NULL column. Too bad that MySQL doesn't support the CHECK constraint yet, since that would allow you to fix the problem... For now, you'll need to prevent it using web page or client side code.