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 |
||
Line 1: | Line 1: | ||
It is difficult to confirm if these are all officially part of the SQL spec without purchasing it.<br> | |||
is | 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) # (N-bytes, ) | |||
DOUBLE # | |||
</syntaxhighlight> | |||
</blockquote><!-- Numbers --> | |||
Revision as of 17:08, 19 September 2021
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) # (N-bytes, ) DOUBLE #