Database/SQL Server

SQL Server - MS SQL - 기초 교육 자료 - 데이터 타입

청렴결백한 만능 재주꾼 2022. 4. 5. 05:30
반응형

정확한 숫자 Exact numerics

Type Range Storage
bigint -2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807) 8 Bytes
int -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647) 4 Bytes
smallint -2^15 (-32,768) to 2^15-1 (32,767) 2 Bytes
tinyint 0 to 255 1 Byte

대략의 숫자 Approximate numerics

 

Type Range Storage
float - 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308 Depends on the value of n
real - 3.40E + 38 to -1.18E - 38, 0 and 1.18E - 38 to 3.40E + 38 4 Bytes

Float

n Value Precision Storage Size
1-24 7 digits 4 bytes
25-53 15 digits 8 bytes

 

 

 

날짜 및 시간 Date and Datetime

 

date description

 

Property Value
Syntax date
Usage DECLARE @MyDate date

CREATE TABLE Table1 ( Column1 date )
Default string literal format

(used for down-level client)
YYYY-MM-DD

For more information, see the "Backward Compatibility for Down-level Clients" section that follows.
Range 0001-01-01 through 9999-12-31 (1582-10-15 through 9999-12-31 for Informatica)

January 1, 1 CE (Common Era) through December 31, 9999 CE (October 15, 1582 CE through December 31, 9999 CE for Informatica)
Element ranges YYYY is four digits from 0001 to 9999 that represent a year. For Informatica, YYYY is limited to the range 1582 to 9999.

MM is two digits from 01 to 12 that represent a month in the specified year.

DD is two digits from 01 to 31, depending on the month, that represents a day of the specified month.
Character length 10 positions
Precision, scale 10, 0
Storage size 3 bytes, fixed
Storage structure 1, 3-byte integer stores date.
Accuracy One day
Default value 1900-01-01

This value is used for the appended date part for implicit conversion from time to datetime2 or datetimeoffset.
Calendar Gregorian
User-defined fractional second precision No
Time zone offset aware and preservation No
Daylight saving aware No

 

datetime Description

PropertyValue
Syntax datetime
Usage DECLARE @MyDatetime datetime

CREATE TABLE Table1 ( Column1 datetime )
Default string literal formats

(used for down-level client)
Not applicable
Date range January 1, 1753, through December 31, 9999
Time range 00:00:00 through 23:59:59.997
Time zone offset range None
Element ranges YYYY is four digits from 1753 through 9999 that represent a year.

MM is two digits, ranging from 01 to 12, that represent a month in the specified year.

DD is two digits, ranging from 01 to 31 depending on the month, that represent a day of the specified month.

hh is two digits, ranging from 00 to 23, that represent the hour.

mm is two digits, ranging from 00 to 59, that represent the minute.

ss is two digits, ranging from 00 to 59, that represent the second.

n* is zero to three digits, ranging from 0 to 999, that represent the fractional seconds.
Character length 19 positions minimum to 23 maximum
Storage size 8 bytes
Accuracy Rounded to increments of .000, .003, or .007 seconds
Default value 1900-01-01 00:00:00
Calendar Gregorian (Does include the complete range of years.)
User-defined fractional second precision No
Time zone offset aware and preservation No
Daylight saving aware No

 

그외 datetime2, datetimeoffset, smalldatetime, time 등등이 있음

 

 

문자 String

 

Character strings

 

Char and Varchar

Arguments

Character data types that are either fixed-size, char, or variable-size, varchar. Starting with SQL Server 2019 (15.x), when a UTF-8 enabled collation is used, these data types store the full range of Unicode character data and use the UTF-8 character encoding. If a non-UTF-8 collation is specified, then these data types store only a subset of characters supported by the corresponding code page of that collation.

 

 

nchar and nvarchar

Character data types that are either fixed-size, nchar, or variable-size, nvarchar. Starting with SQL Server 2012 (11.x), when a Supplementary Character (SC) enabled collation is used, these data types store the full range of Unicode character data and use the UTF-16 character encoding. If a non-SC collation is specified, then these data types store only the subset of character data supported by the UCS-2 character encoding.

 

 

반응형