top of page

SQL Data Types

Like any other language, SQL do have his own set of data types which we are going to use as per our requirements. While Creating a table, you have to specify which data type each column is going to have and if you pass value other than the defined one then SQL will throw an error.

datatype.png

String Data Types

String data type is use to store the character values and we should pass the values in quotes.

Data Type
Example
Maximum Size
Description
Character
char(5)
255 Bytes
It can hold maximum of 5 character length data and it is fixed storage data type. if you store even 3 characters than also it will take 5 character place to hold the data.
Variable Character
varchar(10)
65535 Bytes
It can hold up to maximum of 10 characters of data. It is flexible data storage type that means if we try to store 3 character data then it will take only 3 space in the storage.
Enumerate ()
ENUM('M','F')
65535 Values
We pass a set in the value of enum and if the value is not present than it will give null value else it will take the value.

Numeric Data Types

Numeric data type is use to store the integer values and while giving the values its not necessary to give quotes.

numeric type.png

Integer Data Types

Type
Storage
Singed
Minimum Value
Maximum Value
TINYINT
1 Byte
Signed
-128
126
1 Byte
Unsigned
0
255
SMALLINT
2 Bytes
SIgned
-32768
32767
2 Bytes
Unsigned
0
65535
MEDIUMINT
3 Bytes
Signed
-8388608
8388607
3 Bytes
Unsigned
0
16777215
INT
4 Bytes
Signed
-2147483648
2147483647
4 Bytes
Unsigned
0
4294967295
BIGINT
8 Bytes
Signed
-92233720368547780
92233720368547780
8 Bytes
Unisgned
0
184467440737095520

Decimal Data Types

It is a fixed-point numeric data type.

Syntax : decimal(p,s)  

p is precision and s is scale

​

Example:

decimal(5,2)

​

  input          stored value

 345.21         345.21

 567.214       567.21   (With Warning sign)

Float Data Types

It is a floating-point numeric data type.

Syntax : float(p,s)  

p is precision and s is scale

​

Example:

float(5,2)

​

  input          stored value

 345.21         345.21

 567.214       567.21    (Without Warning sign)

Double Data Types

It is a floating-point numeric data type.

Syntax : double(p,s)  

p is precision and s is scale

​

Double is similar to float with only difference is that float can store up to 23 digits and double can store up to 53 digits.

bottom of page