Sql datatypes: Difference between revisions
From wikinotes
No edit summary |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{ NOTE | | |||
It is difficult to confirm if these are all officially part of the SQL spec without purchasing it.<br> | It is difficult to confirm if these are all officially part of the SQL spec without purchasing it.<br> | ||
Always consult your database docs. | Always consult your database docs. | ||
}} | |||
= Text = | = Text = | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang="SQL"> | <syntaxhighlight lang="SQL"> | ||
CHAR(10) | CHAR(10) /* (N-bytes) string. If stores shorter string, remaining space filled with blank characters. */ | ||
VARCHAR(10) | VARCHAR(10) /* (N-bytes) string. Can store shorter strings */ | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Text --> | </blockquote><!-- Text --> | ||
Line 13: | Line 15: | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang="SQL"> | <syntaxhighlight lang="SQL"> | ||
BLOB | BLOB /* (1-byte) binary blob */ | ||
BLOB(10) | BLOB(10) /* (N-bytes) binary blob */ | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Binary Blobs --> | </blockquote><!-- Binary Blobs --> |
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) /* */