dataTypesSQL

download dataTypesSQL

of 11

Transcript of dataTypesSQL

  • 7/25/2019 dataTypesSQL

    1/11

    SQL Server

    2008Data Types

  • 7/25/2019 dataTypesSQL

    2/11

    Data types are the most

    fundamental constraintelement of a database in

    that it restricts the rangeof possible values that

    are allowed to be storedwithin a column.

  • 7/25/2019 dataTypesSQL

    3/11

    Numeric data

    ne of the most commondata types that you will

    !nd within SQL Serverare numeric data types.

    There are ten numericdata types that ship withSQL Server 2008.

  • 7/25/2019 dataTypesSQL

    4/11

    " #our data types are

    designed to store integervalues of various si$es.

    " Two data types aredesigned to storemonetary data." Three data types aredesigned to store

    decimal%based numbers

  • 7/25/2019 dataTypesSQL

    5/11

    Data Type Range of Value StorageSpace

    tinyint 0 to 2&& ' byte

    smallint %(2)*+8 to (2)*+* 2 bytesint %2(' to 2(' %' , bytes

    bigint %2+( to 2+( %' 8 bytes

    decimal-p)snumeric-p)s

    %'0(8 to '0(8 %' & to '* bytes

    smallmoney %2',)*,8.(+,8 to 2',)*,8.(+,* , bytes

    money %/22)((*)20()+8&),**.&808 to/22)((*)20()+8&),**.&80*

    8 bytes

    real %(.,(8 to %'.'8(8 ) 0) and '.'8(8

    to (.,(8, bytes

    #loat %'.*/(08 to %2.2((08 ) 0) and2.2((08 to '.*/(08

    , bytes or 8bytes

  • 7/25/2019 dataTypesSQL

    6/11

    Character data type

    char-n % ' byte percharacter de!ned by n up

    to a maimum of 8000bytes

    varchar-n %' byte percharacter stored up to amaimum of 8000 bytes

  • 7/25/2019 dataTypesSQL

    7/11

    Character data type

    tet %' byte percharacter stored up to a

    maimum of 2 1nchar-n %2 bytes per

    character de!ned by n upto a maimum of ,000bytes

  • 7/25/2019 dataTypesSQL

    8/11

    Character data type

    nvarchar-n% 2 bytes percharacters stored up to a

    maimum of ,000 bytesntet% 2 bytes per

    character stored up to amaimum of 2 1

  • 7/25/2019 dataTypesSQL

    9/11

    Date and Time Data

    smalldatetime0'30'3'/00 to

    0+30+320*/

    datetime0'30'3'*&( to'23('3////

  • 7/25/2019 dataTypesSQL

    10/11

    Date and Time Data

    time00400400.0000000

    to 2(4&/4&/.///////

  • 7/25/2019 dataTypesSQL

    11/11

    Binary Data

    bit 5ull) 0 and ' 'bit