SQL Data Types: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 48: Line 48:
Variable-length storage with a maximum length of 8,000 characters.
Variable-length storage with a maximum length of 8,000 characters.
==<tt>VARCHAR(max)</tt>==
==<tt>VARCHAR(max)</tt>==
Variable-length storage with provided max characters, not supported in MySQL.
Variable-length storage with provided max characters. Not supported in MySQL.
 
==<tt>TEXT</tt>==
==<tt>TEXT</tt>==
Variable-length storage with a maximum size of 2GB data.
Variable-length storage with a maximum size of 2GB data.

Revision as of 23:49, 22 May 2024

External

Internal

Overview

TODO

  • Database-specific data types
  • Working with different data types
  • Conversion functions

Numeric Data Types

BIT

0,1

TINYINT

0..255

SMALLINT

-32,768..32,767

INT

-2,147,483,648..2,147,483,647

BIGINT

-9,223,372,036,854,775,808..9,223,372,036,854,775,807

DECIMAL, NUMERIC

-10^38 + 1 .. 10^38 - 1

FLOAT

-1.79E+308 .. 1.79E+308

REAL

-3.40E+38 .. 3.40E+38

Date and Time Data Types

DATE

Stores date in the format YYYY-MM-DD.

TIME

Stores time in the format HH:MI:SS.

DATETIME

Stores date and time information in the format YYYY-MM-DD HH:MI:SS.

TIMESTAMP

Stores number of seconds passed since the Unix epoch ('1970-01-01 00:00:00' UTC).

YEAR

Stores year in a 2-digit or 4-digit format. Range 1901 to 2155 in 4-digit format. Range 70 to 69, representing 1970 to 2069.

Character and String Data Types

These data types are for character streams, they should not be used with Unicode data.

CHAR

Fixed length with a maximum length of 8,000 characters.

VARCHAR

Variable-length storage with a maximum length of 8,000 characters.

VARCHAR(max)

Variable-length storage with provided max characters. Not supported in MySQL.

TEXT

Variable-length storage with a maximum size of 2GB data.

Unicode Character and String Data Types

These data types are not supported in MySQL databases.

NCHAR

Fixed length with a maximum length of 4,000 characters.

NVARCHAR

Variable-length storage with a maximum length of 4,000 characters.

NVARCHAR(max)

Variable-length storage with provided max characters.

NTEXT

Variable-length storage with a maximum size of 1GB data.

Binary Data Types

BINARY

Fixed length with a maximum length of 8,000 bytes.

VARBINARY

Variable-length storage with a maximum length of 8,000 bytes.

VARBINARY(max)

Variable-length storage with provided max bytes.

IMAGE

Variable-length storage with a maximum size of 2 GB binary data.

Miscellaneous Data Types

CLOB

Character large objects that can hold up to 2 GB.

BLOB

Large binary objects.

XML

XML data.

JSON

JSON data.