reset password
Author Message
clai8
Posts: 8
Posted 21:44 Nov 17, 2014 |

Can anyone tell me what does this mean?

 

CREATE TABLE Members (
      MemberID int PRIMARY KEY ,
      FirstName varchar (25) NULL ,      -------->  what is the value (25) means and what's the NULL mean?? Confused.
 

shewitt2
Posts: 5
Posted 22:28 Nov 17, 2014 |

The (25) basically means that the FirstName field can have a maximum of 25 characters, and the NULL means that MySQL will accept a NULL value for that field.
 

303496263
Posts: 68
Posted 22:32 Nov 17, 2014 |

Lets go line by line:

The first line simply creates a table and names it "Memembers". Then, declares a field/column names "MemberID" with a datatype of int(integer). Also, this field/column is the primary key of the table.

For 3rd line, you declare a fireld/column with a datatype "varchar". According to the documentation of MYSQL, Varchar datatype holds alphanumeric data (letters and numbers).  In this specific case, varchar(25) means that the column will take alphanumeric data of max length of 25.

Then, NULL means that the column will accept NULL values. Think of the "Webaddress" field in the the artists table in the lyric database(it has one NULL value for a webaddress). Instead, if you had the following: Firstname varchar(25) NOT NULL, then you would not be able insert NULL values in the table after creating the table.

Hope this helps.

Last edited by 303496263 at 09:56 Nov 20, 2014.