Jump to content

Need help with MYSQL table code


$Three3

Recommended Posts

Hi, I have just begun to learn about connecting and adding entries to a MYSQL database but I am confused on one part of what I have read so far. When trying to Create a Table in the database, this is what the book says to write:

 

CREATE TABLE entries (entry_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , title VARCHAR(100) NOT NULL, entry TEXT NOT NULL, date_entered DATETIME NOT NULL)

 

What I really do not grasp 100% is what the CAPITAL words really mean. If someone does not mind explaining the what this actually means it would be great. Thanks a lot in advance for the help.

 

Link to comment
Share on other sites

CREATE TABLE - pretty obvious, you ask MySQL to create a table

entry_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY - this is a definition of a column:

INT UNSIGNED - it will be of type INT UNSIGNED http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

NOT NULL - it will not accept empty values

AUTO_INCREMENT - http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

PRIMARY KEY - this column will be a primary key for this table

 

title VARCHAR(100) NOT NULL - that's another column's definition

  VARCHAR(100) this column will be of type VARCHAR with maximum length of 100 http://dev.mysql.com/doc/refman/5.0/en/char.html

 

TEXT - http://dev.mysql.com/doc/refman/5.0/en/blob.html

DATETIME - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-types.html

 

Full explanation of CREATE TABLE syntax - http://dev.mysql.com/doc/refman/5.0/en/create-table.html (It might seem confusing at first, but it actually is pretty well laid out)

 

 

 

Link to comment
Share on other sites

CREATE TABLE - pretty obvious, you ask MySQL to create a table

entry_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY - this is a definition of a column:

INT UNSIGNED - it will be of type INT UNSIGNED http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

NOT NULL - it will not accept empty values

AUTO_INCREMENT - http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

PRIMARY KEY - this column will be a primary key for this table

 

title VARCHAR(100) NOT NULL - that's another column's definition

  VARCHAR(100) this column will be of type VARCHAR with maximum length of 100 http://dev.mysql.com/doc/refman/5.0/en/char.html

 

TEXT - http://dev.mysql.com/doc/refman/5.0/en/blob.html

DATETIME - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-types.html

 

Full explanation of CREATE TABLE syntax - http://dev.mysql.com/doc/refman/5.0/en/create-table.html (It might seem confusing at first, but it actually is pretty well laid out)

 

Thanks a lot man for those links and explanations. It really cleared things up for me. Thanks again

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.