INT or INTEGER - It holds whole number between -32,768 and 32,767 either it is negative or positive. It can not hold a decimal numbers. The maximum number of digits may be specified in parenthesis.
Syntax :-
column_name INT (size);
Ex :-
roll INT (5);
DEC or DECIMAL (size, p) - It holds fixed point numbers, size is the total number of digits and p is the number of digits after the decimal point. The decimal point and the negative sign '-' are not counted in size. If p is 0, values have no decimal point. The maximum number of size for decimal is 65 and for p 30. if p omitted the default is 0. if size is omitted, the default is 10.
Syntax :-
column_name DECIMAL(size, p);
Ex :-
price DECIMAL (4,2);
CHAR or CHARACTER - It holds a fixed length string (can contain letter, numbers, and special characters). The fixed size is specified in parenthesis. It can store up to 255haracters.
Syntax :-
column_name CHAR (20);
Ex :-
name CHAR (20);
VARCHAR - It holds a variable length string (can contains letters, numbers, and special character). The maximum size is specified parenthesis. It can store up to 255 characters.
Note : If we put a greater value than 255 it will be converted to a TEXT type.
Syntax :-
column_name VARCHAR (size);
Ex :-
name VARCHAR (50);
TEXT - It holds a string with a maximum length of 65,535 characters.
Syntax :-
column_name TEXT;
Ex :-
address TEXT;
DATE - It display Date values in yyyy-mm-dd format.
Syntax :-
column_name DATE;
Ex :-
age DATE;
DATATIME - It display DATETIME values in yyyy-mm-dd hh:mm:ss format.
Syntax :-
column_name DATETIME;
Ex :-
Date_of_join DATETIME;
TIMESTAMP - It also displayes date and time.
Syntax :-
column_name TIMESTAMP;
Ex :-
login_dt TIMESTAMP;
Syntax :-
column_name INT (size);
Ex :-
roll INT (5);
DEC or DECIMAL (size, p) - It holds fixed point numbers, size is the total number of digits and p is the number of digits after the decimal point. The decimal point and the negative sign '-' are not counted in size. If p is 0, values have no decimal point. The maximum number of size for decimal is 65 and for p 30. if p omitted the default is 0. if size is omitted, the default is 10.
Syntax :-
column_name DECIMAL(size, p);
Ex :-
price DECIMAL (4,2);
CHAR or CHARACTER - It holds a fixed length string (can contain letter, numbers, and special characters). The fixed size is specified in parenthesis. It can store up to 255haracters.
Syntax :-
column_name CHAR (20);
Ex :-
name CHAR (20);
VARCHAR - It holds a variable length string (can contains letters, numbers, and special character). The maximum size is specified parenthesis. It can store up to 255 characters.
Note : If we put a greater value than 255 it will be converted to a TEXT type.
Syntax :-
column_name VARCHAR (size);
Ex :-
name VARCHAR (50);
TEXT - It holds a string with a maximum length of 65,535 characters.
Syntax :-
column_name TEXT;
Ex :-
address TEXT;
DATE - It display Date values in yyyy-mm-dd format.
Syntax :-
column_name DATE;
Ex :-
age DATE;
DATATIME - It display DATETIME values in yyyy-mm-dd hh:mm:ss format.
Syntax :-
column_name DATETIME;
Ex :-
Date_of_join DATETIME;
TIMESTAMP - It also displayes date and time.
Syntax :-
column_name TIMESTAMP;
Ex :-
login_dt TIMESTAMP;
0 Comments:
Post a Comment