<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NewSourceMedia Blog &#187; Fields</title>
	<atom:link href="http://newsourcemedia.com/blog/tag/fields/feed/" rel="self" type="application/rss+xml" />
	<link>http://newsourcemedia.com/blog</link>
	<description>Focused on Interactive Design, Development and Marketing</description>
	<lastBuildDate>Fri, 30 Dec 2011 04:30:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>MySQL Table Fields Data Types</title>
		<link>http://newsourcemedia.com/blog/mysql-table-fields-data-types/</link>
		<comments>http://newsourcemedia.com/blog/mysql-table-fields-data-types/#comments</comments>
		<pubDate>Tue, 26 Dec 2006 00:22:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL / Database]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Data Typs.]]></category>
		<category><![CDATA[Fields]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Table]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/2006/12/25/mysql-table-fields-data-types/</guid>
		<description><![CDATA[Learn MySQL data types like Numeric Types, Date and Time Types and String Types for building dynamic web sites. Learn the three main basic data types used in MySQL and how to utilize them to build a more effective dynamic &#8230; <a href="http://newsourcemedia.com/blog/mysql-table-fields-data-types/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[Learn MySQL data types like Numeric Types, Date and Time Types and String Types for building dynamic web sites.
<span id="more-180"></span>

Learn the three main basic data types used in MySQL and how to utilize them to build a more effective dynamic web site. Lots of web developers use MySQL but not all of them harness the power of these features.

<strong>The three main types of data types used in MySQL are</strong>
1) Numeric (Integer/Numbers/Money)
2) String (Text)
3) Date (Dates and Time)

It's very important to pick the right data to achieve speed, effective storage and data retrieval. Here is a introduction to data types:
<h3><span class="nothing">Numeric Data Types</span></h3>
In addition to <strong>int</strong> (Integer data type), MySQL also has provision for floating-point and double precision numbers. Each integer type can take also be UNSIGNED and/or AUTO_INCREMENT.
<ul>
	<li><strong>TINYINT</strong>: very small numbers; suitable for ages. Actually, we should have used this data type for employee ages and number of children. Can store numbers between 0 to 255 if UNSIGNED clause is applied, else the range is between -128 to 127.</li>
	<li><strong>SMALLINT</strong>: Suitable for numbers between 0 to 65535 (UNSIGNED) or -32768 to 32767.</li>
	<li><strong>MEDIUMINT</strong>: 0 to 16777215 with UNSIGNED clause or -8388608 to 8388607.</li>
	<li><strong>INT</strong>: UNSIGNED integers fall between 0 to 4294967295 or -2147683648 to 2147683647.</li>
	<li><strong>BIGINT</strong>: Huge numbers. (-9223372036854775808 to 9223372036854775807)</li>
	<li><strong>FLOAT</strong>: Floating point numbers (single precision)</li>
	<li><strong>DOUBLE</strong>: Floating point numbers (double precision)</li>
	<li><strong>DECIMAL</strong>:Floating point numbers represented as strings.</li>
</ul>
<h3>Date and Time Data types</h3>
	<li><strong>DATE</strong>: YYYY-MM-DD (Four digit year followed by two digit month and date)</li>
	<li><strong>TIME</strong>: hh:mm:ss (Hours:Minutes:Seconds)</li>
	<li><strong>DATETIME</strong>: YYYY-MM-DD hh:mm:ss (Date and time separated by a space character)</li>
	<li><strong>TIMESTAMP</strong>: YYYYMMDDhhmmss</li>
	<li><strong>YEAR</strong>: YYYY (4 digit year)</li>
<h3>Text Data Type</h3>
Text can be fixed length (char) or variable length strings. Also, text comparisions can be case sensitive or insensitive depending on the type you choose.
<ul>
	<li><strong>CHAR(x)</strong>: where x can range from 1 to 255.</li>
	<li><strong>VARCHAR(x)</strong>: x ranges from 1 - 255</li>
	<li><strong>TINYTEXT</strong>: small text, case insensitive</li>
	<li><strong>TEXT</strong>: slightly longer text, case insensitive</li>
	<li><strong>MEDIUMTEXT</strong>: medium size text, case insensitive</li>
	<li><strong>LONGTEXT</strong>: really long text, case insensitive</li>
	<li><strong>TINYBLOB</strong>: Blob means a <strong>B</strong>inary <strong>L</strong>arge <strong>OB</strong>ject. You should use blobs for case sensitive searches.</li>
	<li><strong>BLOB</strong>: slightly larger blob, case sensitive.</li>
	<li><strong>MEDIUMBLOB</strong>: medium sized blobs, case sensitive.</li>
	<li><strong>LONGBLOB</strong>: really huge blobs, case sensitive.</li>
	<li><strong>ENUM</strong>: <strong>Enum</strong>eration data type have fixed values and the column can take only one value from the given set. The values are placed in parenthesis following ENUM declaration. An example, is the marital status column we encountered in <em>employee_per</em> table.
<pre class="code">m_status ENUM("Y", "N")</pre>
Thus, m_status column will take only <strong>Y</strong> or <strong>N</strong> as values. If you specify any other value with the INSERT statement, MYSQL will not return an error, it just inserts a NULL value in the column.</li>
	<li><strong>SET</strong>: An extension of ENUM. Values are fixed and placed after the SET declaration; however, SET columns can take multiple values from the values provided. Consider a column with the SET data type as
<pre class="code">foods SET ("Apples", "Cookies", "Pies", "Chicken")</pre>
You can have 0 or all the four values in the column.
<pre class="code">INSERT tablename (foods) values ("Apple", "Cookies");</pre>
</li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/mysql-table-fields-data-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
