Difference between revisions of "MySQL"

Jump to navigation Jump to search
390 bytes added ,  14:22, 14 January 2011
→‎Data Types: Added Strings
(→‎CREATE / ALTER Tables: Added further ALTER examples)
(→‎Data Types: Added Strings)
Line 47: Line 47:


== Data Types ==
== Data Types ==
=== NULL ===
NULL means "no data", it doesn't mean zero.  Therefore 0 <> NULL in an numerical field, and "NULL" <> NULL in a string field.
To set a field to NULL, use NULL without any quotes eg...
<source lang="mysql">INSERT INTO table (col1, col2) VALUES ('data1', NULL); </source>
=== Numbers ===
=== Numbers ===


Line 80: Line 74:
| <code> BIGINT UNSIGNED </code>    || 8    || 0                    || 18446744073709551615
| <code> BIGINT UNSIGNED </code>    || 8    || 0                    || 18446744073709551615
|}
|}
=== Strings ===
There's two main string types
* '''<code>VARCHAR</code>''' - Variable character length up a prescribed maximum (eg <code>VARCHAR(32)</code>). Max allowed is 65,535 (though in reality this max width is shared across all columns so is less in practice.
* '''<code>CHAR</code>''' - Fixed character length up a prescribed maximum (eg <code>CHAR(32)</code>). Max allowed is 255
=== NULL ===
NULL means "no data", it doesn't mean zero.  Therefore 0 <> NULL in an numerical field, and "NULL" <> NULL in a string field.
To set a field to NULL, use NULL without any quotes eg...
<source lang="mysql">INSERT INTO table (col1, col2) VALUES ('data1', NULL); </source>


=== IP Addresses ===
=== IP Addresses ===

Navigation menu