Thursday, December 27, 2012

Common MySql Field Data Types


MySql : Common Field Data Types:
By Stephon Unomon
Google +

 

CHAR() – Fixed length field between 0 and 255 characters that can store any type of data. The length of the field is set regardless of the size of the data placed into it.

DATE – Date in YYYY-MM-DD format.

INT – Whole numbers only.  The number of digits can also be specified in parentheses, but is not necessary.

TEXT – Variable length text-only field with a maximum length of 65535 characters.

TIME – Time in hh:mm:ss format.

VARCHAR() – Variable length field between 0 and 255 characters that can store any type of data.  Unlike the CHAR() type, the length of each VARCHAR() field is determined by the data placed into it.

 

So, knowing this, let’s decipher our code example from above.

 

<?php mysql_query(“

CREATE TABLE Employees

(open the query to the DB and make this table with Employees as the name)

 

(employee_id INT,

(make this field with employee_id as the name and allow only whole numbers)

 

first_name VARCHAR(50),

(make this field with first_name as the name, allow any input, and limit it to 50 characters in length)

 

last_name VARCHAR(50)”)

(make this field with last_name as the name, allow any input, and limit it to 50 characters in length)

?>

Once you get the basic concepts, data manipulation with MySQL is not difficult. Let’s dive in a little bit more to the way tables are laid out.
 
 
Save Time While Building PHP Applications
Check Out
The #1 PHP GUI Controls

No comments:

Post a Comment