Sql datatypes: Difference between revisions
From wikinotes
No edit summary |
|||
Line 21: | Line 21: | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang="SQL"> | <syntaxhighlight lang="SQL"> | ||
BOOLEAN | BOOLEAN /* true/false, TRUE/FALSE */ | ||
SMALLINT | SMALLINT /* (2-bytes, signed) -32_768 ... 32_767 */ | ||
INT | INT /* (4-bytes, signed) -2_147_483_648 ... 2_147_483_647 */ | ||
BIGINT | BIGINT /* (8-bytes, signed) -9_223_372_036_854_775_808 ... -9_223_372_036_854_775_807 */ | ||
DECIMAL | DECIMAL /* (10-digits, 0-decimal-places) -1_000_000_000 ... 1_000_000_000 */ | ||
DECIMAL(10, 2) | DECIMAL(10, 2) /* (10-digits, 2-decimal-places) -1_000_000_000.00 ... 1_000_000_000.00 */ | ||
FLOAT(10) | FLOAT(10) /* (N-bytes) */ | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Numbers --> | </blockquote><!-- Numbers --> |
Revision as of 17:10, 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) */