adding 'not null' mysql column


How do I change this:

mysql_query("ALTER TABLE samples ADD Nov_03 TEXT");

so that the column it sets up is not null?

Thanks,

Chris
ChrisAndrewsAsked:
Who is Participating?
 
yahelbConnect With a Mentor Commented:
ALTER TABLE samples CHANGE Nov_03 Nov_03 TEXT NOT NULL
0
 
ChrisAndrewsAuthor Commented:

Thank you, that works :)

So does it always have to be set up (ADD) and then changed (CHANGE) to make it not null?  It's not something that you can indicate in the ADD statment?

Chris
0
 
yahelbCommented:
no you can do that with add
ALTER TABLE sample ADD Nov_03 TEXT NOT NULL.

but since the field Nov_03 already exist you just needed to change it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.