Data Types In SQL
What is Data
Type?
A data type as the name suggests it is the
type or category to which the data belongs to. A data type specifies a
particular type of data, such as integer, floating-point, Boolean, etc. In SQL,
the data type defines the type of data to be stored in each column of a table.
SQL data
types can be broadly divided into three categories
1. Numeric Data Types
2. String Data Types
3. Data & Time Data Types
Numeric Data Types |
String Data Types |
Data&Time DataTypes |
|
BIT |
CHAR(SIZE) |
DATE |
|
TINYINT |
VARCHAR(SIZE) |
TIME |
|
SMALLINT |
TEXT(SIZE) |
DATETIME |
|
MEDIUMINT |
TINYTEXT(SIZE) |
TIMESTAMP |
|
INT |
MEDIUMTEXT(SIZE) |
YEAR |
|
BIGINT |
LONGTEXT |
|
|
FLOAT |
BINARY |
|
|
DOUBLE |
ENUM |
|
|
BOOLEAN |
SET |
|
|
Most commonly used data types 1.
INT : The signed range is -2147483648 to 2147483647.
The unsigned range is 0 to 4294967295. 2.
CHAR Or VARCHAR
: The CHAR and VARCHAR types are
declared with a length that indicates the maximum number of characters you
want to store. For example, CHAR(30) can hold up to 30 characters. 3.
DATE & TIME
Data Types: a) DATE
: Stores date in the format of
YYY-MM-DD. b) TIME
: Stores time in the format of HH:MI:SS. c) DATATIME
: Stores date and time information in
the format of YYYY-MM-DD HH:MI:SS. d) TIMESTAMP
: Stores number of second passed science
the Unix epoch (‘1970-01-01 00:00:00’ UTC). YEAR
: MySQL displays YEAR values
in YYYY format, with a range of 1901 to 2155,
and 0000. |
|||
Comments
Post a Comment