MySQL Data Types
Data Types:
is a restriction where we can place it on top of column
Integer(int):
it will accept only numerics
Char(n):
it will accept alphanumaric and special characters
Varchar(n):
it will accept alphanumaric and special characters
Difference between char and varchar?
Char:
VarChar:
Date:
it will accept only dates
Datetime:
it will accept dates along with time
Money:
it will accepts only money values
Boolean:
it will accepts only boolean values(i.e true/false)
Image:
it will accepts images(photos)
Float:
it will accept decimal values
Text:
will accepts ‘n’ number of characters
Data Types:
is a restriction where we can place it on top of column
Integer(int):
it will accept only numerics
Char(n):
it will accept alphanumaric and special characters
Varchar(n):
it will accept alphanumaric and special characters
Difference between char and varchar?
Char:
1.Fixed length memory storage
2.CHAR takes up 1 byte per character
3.Use Char when the data entries in a column are expected to be the same size
5.Ex:
Declare test Char(100);
test="Test" -
Then "test" occupies 100 bytes first four bytes with values and rest with blank data.
VarChar:
1.Variable length memory storage(Changeable)
2.VARCHAR takes up 1 byte per character, + 2 bytes to hold length information
3.varchar when the data entries in a column are expected to vary considerably in size.
4.Ex:
Declare test VarChar(100);
test="Test" -
Then "test" occupies only 4+2=6 bytes. first four bytes for value and other two bytes for variable length information.
Date:
it will accept only dates
Datetime:
it will accept dates along with time
Money:
it will accepts only money values
Boolean:
it will accepts only boolean values(i.e true/false)
Image:
it will accepts images(photos)
Float:
it will accept decimal values
Text:
will accepts ‘n’ number of characters
No comments:
Post a Comment