Sql datatypes

From wikinotes
Revision as of 17:08, 19 September 2021 by Will (talk | contribs)

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            #