Wednesday, February 4, 2015

SQL Data Types


SQL Data Types


The SQL data type defines a kind of value that a column can contain.
In a database table, every column is required to have a name and a data type.

Data Type varies from database to database. For example, MySQL supports INT but Oracle supports NUMBER for integer values.

These are the general data types in SQL.
Data-typeSyntaxExplanation
IntegerINTEGERinteger number.
SmallintSMALLINTsmall integer number.
NumericNUMERIC(P,S)where 'p' is precision value and 's' is scale value.
RealREALsingle precision floating point number
DecimalDECIMAL(P,S)where 'p' is precision value and 's' is scale value.
Double precisionDOUBLE PRECISIONdouble precision floating point number
FloatFLOAT(P)where 'p' is precision value
CharacterCHAR(X)where 'x' is the character's number to store
Character varyingVARCHAR2(X)where 'x' is the character's number to store
BitBIT(X)where 'x' is the number of bits to store
Bit varyingBIT VARYING(X)'x' is the number of bits to store (length can vary up to x)
DateDATEit stores year, month and days values.
TimeTIMEit stores hour, minute and second values
TimestampTIMESTAMPit stores year, month, day, hour, minute and second values
Time withTIME WITHexactly same as time but also store an offset from UTC
time zoneTIME ZONEof the time specified
timestamp withTIMESTAMP WITHsame as timestamp but also stores an offset from UTC of
time zoneTIME ZONEthe time specified.

No comments:

Post a Comment