Sql datatypes: Difference between revisions
From wikinotes
(Created page with "{{ TODO | is this all SQL? or is this MySQL specific? }} {| class="wikitable" !colspan=2| Integers |- | <code>UNIQUE</code> || I need to lookup how this works....") |
No edit summary |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{ | {{ NOTE | | ||
is | It is difficult to confirm if these are all officially part of the SQL spec without purchasing it.<br> | ||
Always consult your database docs. | |||
}} | |||
= Text = | |||
<blockquote> | |||
<syntaxhighlight lang="SQL"> | |||
CHAR(10) /* (N-bytes) string. If stores shorter string, remaining space filled with blank characters. */ | |||
VARCHAR(10) /* (N-bytes) string. Can store shorter strings */ | |||
</syntaxhighlight> | |||
</blockquote><!-- Text --> | |||
= Blobs = | |||
<blockquote> | |||
<syntaxhighlight lang="SQL"> | |||
BLOB /* (1-byte) binary blob */ | |||
BLOB(10) /* (N-bytes) binary blob */ | |||
</syntaxhighlight> | |||
</blockquote><!-- Binary Blobs --> | |||
= Numbers = | |||
<blockquote> | |||
<syntaxhighlight lang="SQL"> | |||
BOOLEAN /* true/false, TRUE/FALSE */ | |||
SMALLINT /* (2-bytes, signed) -32_768 ... 32_767 */ | |||
INT /* (4-bytes, signed) -2_147_483_648 ... 2_147_483_647 */ | |||
BIGINT /* (8-bytes, signed) -9_223_372_036_854_775_808 ... -9_223_372_036_854_775_807 */ | |||
DECIMAL /* (10-digits, 0-decimal-places) -1_000_000_000 ... 1_000_000_000 */ | |||
DECIMAL(10, 2) /* (10-digits, 2-decimal-places) -1_000_000_000.00 ... 1_000_000_000.00 */ | |||
FLOAT(10) /* */ | |||
</syntaxhighlight> | |||
</blockquote><!-- Numbers --> | |||
Latest revision as of 19:07, 19 September 2021
NOTE:
It is difficult to confirm if these are all officially part of the SQL spec without purchasing it.
Always consult your database docs.
Text
CHAR(10) /* (N-bytes) string. If stores shorter string, remaining space filled with blank characters. */ VARCHAR(10) /* (N-bytes) string. Can store shorter strings */
Blobs
BLOB /* (1-byte) binary blob */ BLOB(10) /* (N-bytes) binary blob */
Numbers
BOOLEAN /* true/false, TRUE/FALSE */ SMALLINT /* (2-bytes, signed) -32_768 ... 32_767 */ INT /* (4-bytes, signed) -2_147_483_648 ... 2_147_483_647 */ BIGINT /* (8-bytes, signed) -9_223_372_036_854_775_808 ... -9_223_372_036_854_775_807 */ DECIMAL /* (10-digits, 0-decimal-places) -1_000_000_000 ... 1_000_000_000 */ DECIMAL(10, 2) /* (10-digits, 2-decimal-places) -1_000_000_000.00 ... 1_000_000_000.00 */ FLOAT(10) /* */