0% found this document useful (0 votes)
30 views

15-SQL Data Types

The document discusses the main data types in SQL including string, numeric, and date/time types. It provides the datatype name and a description of what each type represents and constraints like maximum sizes.

Uploaded by

Akshat Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

15-SQL Data Types

The document discusses the main data types in SQL including string, numeric, and date/time types. It provides the datatype name and a description of what each type represents and constraints like maximum sizes.

Uploaded by

Akshat Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

We have 3 main types of data types-

String Data Types:

Datatype Description
CHAR(size) A FIXED length string (can contain letters, numbers, and
special characters). The size parameter specifies the
column length in characters - can be from 0 to 255.
Default is 1

VARCHAR(size) A VARIABLE length string (can contain letters, numbers,


and special characters). The size parameter specifies the
maximum column length in characters - can be from 0 to
65535

BINARY(size) Equal to CHAR(), but stores binary byte strings. The size
parameter specifies the column length in bytes. Default is
1

VARBINARY(size) Equal to VARCHAR(), but stores binary byte strings. The


size parameter specifies the maximum column length in
bytes.

Numeric Data Types:

Datatype Description
BIT(size) A bit-value type. The number of bits per value is specified
in size. The size parameter can hold a value from 1 to 64.
The default value for size is 1.

TINYINT(size) A very small integer. Signed range is from -128 to 127.


Unsigned range is from 0 to 255. The size parameter
specifies the maximum display width (which is 255)

BOOLEAN Zero is considered as false, nonzero values are


(Not in MySQL) considered as true.
INT(size)/ Signed range is from -2147483648 to 2147483647.
INTEGER(size) Unsigned range is from 0 to 4294967295. The size
parameter specifies the maximum display width (which is
255)

FLOAT(p) A floating point number. MySQL uses the p value to


determine whether to use FLOAT or DOUBLE for the
resulting data type. If p is from 0 to 24, the data type
becomes FLOAT(). If p is from 25 to 53, the data type
becomes DOUBLE()

DECIMAL(size, d) An exact fixed-point number. The total number of digits is


specified in size. The number of digits after the decimal
point is specified in the d parameter. The maximum
number for size is 65. The maximum number for d is 30.
The default value for size is 10. The default value for d is
0.

Date and Time Data Types:

Datatype Description
DATE Format: YYYY-MM-DD. The supported range is from
'1000-01-01' to '9999-12-31'

DATETIME A date and time combination. Format: YYYY-MM-DD


hh:mm:ss. The supported range is from '1000-01-01
00:00:00' to '9999-12-31 23:59:59'.

TIME Format: hh:mm:ss. The supported range is from


'-838:59:59' to '838:59:59'

TIMESTAMP TIMESTAMP values are stored as the number of seconds


since the Unix epoch ('1970-01-01 00:00:00' UTC).
Format: YYYY-MM-DD hh:mm:ss. The supported range is
from '1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07'
UTC.

You might also like