MySQL Forums
Forum List  »  PHP

What is the proper default value for VARCHAR?
Posted by: Harvey Norris
Date: November 07, 2016 10:29AM

Hello MySQL Forums;

Question 1: Should I use a). NULL column default or b). "None" (NOT NULL) column default with a text string as the default value for a VARCHAR column in a MySQL table?

- If I change the VARCHAR column to 'None' using phpMyAdmin (MySQL sets the column to "NOT NULL") I must insert at least one character for the default or the INSERT clause won't work. A popup appears at the Default heading in phpMyAdmin that says "For default values ... enter text in the following format: a."

- If I change the VARCHAR column to 'NULL' the INSERT clause will work.

I have got a database hosting that uses MySQL. The parameters for the database are as follows:

- MySQL server version: 5.6.30
- Shared hosting GoDaddy
- strict SQL mode

The MySQL Manual says that if the column is set to NOT NULL and there is no default value MySQL will define the column with an explicit DEFAULT NULL clause. However, if I export the table it is defined as NOT NULL with no default clause.

The Manual says if the column is set to NOT NULL and if MySQL is set in strict mode the INSERT clause won't work if there is no value for that column.

http://dev.mysql.com/doc/refman/5.6/en/data-type-defaults.html


Thank you in advance.

Options: ReplyQuote


Subject
Written By
Posted
What is the proper default value for VARCHAR?
November 07, 2016 10:29AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.