Home > database >  Mysql based problem
Mysql based problem

Time:09-20

The create table userdata_school (
Id int primary key auto_increment,//system id
Name a varchar (20),//user name
The PWD varchar (20),//password
Phonenum varchar (100),
);

Mysql is excuse me this table, such as when I insert the not give phonenum assignment, so at the time of reading phonenum, the system will give me a null. I'm a little hate this empty, do you have experience of predecessors, what should I do better?

CodePudding user response:


If you don't want to be a null value, so what do you think about it, what do you want a value, then this value is set to the default value is ok

CodePudding user response:

reference 1/f, generation of princess reply:
if you don't want to be a null value, so what do you think about it, what do you want a value, then this value is set to the default value is ok

Agree, you build table, show it to assign an initial value, attribute is set to null

CodePudding user response:

The SELECT phonenum, IFNULL (userdata_school, ' '), IFNULL (userdata_school, 'default') FROM userdata_school;

CodePudding user response:

Phonenum varchar (100) the default ',

CodePudding user response:

To set the default value is default

CodePudding user response:

Built the predicative clause also has a problem, the last field, more than a comma phonenum varchar (100), is changed to phonenum varchar (100); Otherwise, an

CodePudding user response:

I prefer to null, the default value cannot be said of lack of data, for the column does not allow null values, can add the not null constraints,
  • Related