SQL Datatypes

Datatypes In SQL


The following are the list of datatype avialable in SQL .

  •   Numeric .
  •   Character String .
  •   Bit String .
  •   Boolean .
  •   Date ,Time and Timestamp .


Lets Describe Each of the above mentioned datatype in detail .

Numeric: -

DataType Description
Interger This datatype is used to store integer type value

for various size of number this data type is classified into

 int

 small int

 medium int

 large int 



 Ex :- age int

          here age is a variable of type integer .
Float or Real      This datatype is used to store floating point number



 Ex:- price float

        here price is a variable of type float .
Decimal This datatype is used to store Formatted number .



 Decimal(i,j) or dec(i,j) or Numeric(i,j)

     i :- specifies number of digits before decimal . 

     j :- specifies number of digits after decimal .



  Ex:- amount Decimal(4,2)

         here amount is a variable of type decimal .

        the format of values it can store is ( 1000.50 ,3003.60 ,9090.90 ) .







Character - String :-

DataType Description
Char(n)  Char(n) datatype is used to store a fixed length 'n' of character

Varchar(n)      Varchar(n) datatype is used to store a variable length of character
CLOB  CLOB datatype is used to store large text values such as document








Bit String :-

DataType Description
Bit(n)  Bit(n) datatype is used to store a fixed length 'n' of Binary data

Bit Varying(n)     Bit varying(n) datatype is used to store a variable length of Binary data   
BLOB  BLOB datatype is used to store large Binary values such as image




Boolean:-

DataType Description
Boolean         Usually Boolean datatype have value either true or false .



 In Sql because of presence of Null value another value for this is UNKNOWN.



 so possible values of Boolean data type in SQL are

     TRUE

     FALSE

     UNKNOWN.




Date , Time  and TimeStamp :-

DataType Description
DATE  The date datatype has 10 position in the form YYYY-MM-DD 

   Ex:- '2012-12-04'
TIME The time datatype has 8 position in the form HH:MM:SS

   Ex:- '09:12:47'
TIMESTAMP The timestamp datatype include the date and time fields plus fraction of seconds

    Ex:- 2012-12-04 09:12:47 648302'



No comments:

Post a Comment