डाउनलोड पी.डी.एफ. ई-बुक्स
SQL - Data Types

SQL अलग-अलग Data Types रखता है जैसे कि, Numeric, Characters, Binary, date और time जैसे Data Types होते है |

जब SQL में table को create करना पड़ता है तब table के हर column के लिए उसका data type देना पड़ता है |

User अपने जरुरत के मुताबिक data type को चुन सकता है |


Numeric Data Types in SQL

Data TypeSyntaxRange
IntegerINT-231 to +231-1(-2,14,74,83,648 to +2,14,74,83,647)
Small IntegerSMALLINT-215 to +215-1(-32768 to +32767)
Big IntegerBIGINT-263 to +263-1(92,23,37,20,36,85,47,75,808 to +92,23,37,20,36,85,47,75,807)
Tiny IntegerTINYINT0 to +28-1(0 to 255)
BitBIT0 or 1
Numeric(Precision, Scale)NUMERIC(Precision, Scale)-1038+1 to +1038-1(-1.e+38 to +1.e+38)
Decimal or DecDECIMAL(Precision, Scale) or
DEC(Precision, Scale)
-1038+1 to +1038-1(-1.e+38 to +1.e+38)
FloatFLOAT(Precision)-1.79E+308 to +1.79E+308
RealREAL-3.40E + 38 to +3.40E + 38

 

 

Character Data Types

Data TypeSyntaxRange
Character StringCHARMaximum 8,000 characters
Character StringVARCHARMaximum 8,000 characters
Unicode Character StringNCHARMaximum 4,000 characters
Unicode Character StringNVARCHARMaximum 4,000 characters
Character StringTEXTMaximum 231 = 2,147,483,647 characters
Unicode Character StringNTEXTMaximum 230 = 1,073,741,823 characters

 

 

Binary Data Types

Data TypeSyntaxRange
Binary ValueBINARYMaximum 8,000 Bytes
Binary ValueVARBINARYMaximum 8,000 Bytes
ImageIMAGEMaximum 231 = 2,147,483,647 Bytes

 

 

Date and Time Data Types

Data TypeSyntaxExample
dateDATEFor Example, Feb 27, 2015(Format : YYYY-MM-DD)
timeTIMEFor Example, 2:15 A.M.(format : )
datetimeDATETIMERange : January 1, 1753 to December 31, 9999(format : YYYY-MM-DD HH:MI:SS)
smalldatetimeSMALLDATETIMERange : January 1, 1900 to June 6, 2079(format : YYYY-MM-DD HH:MI:SS)
timestampTIMESTAMPformat : YYYY-MM-DD HH:MI:SS (store year, month, day, hour, minute and second)