SQL-데이터 유형
SQL 데이터 유형은 모든 개체의 데이터 유형을 지정하는 속성입니다. 각 열, 변수 및 표현식에는 SQL의 관련 데이터 유형이 있습니다. 테이블을 생성하는 동안 이러한 데이터 유형을 사용할 수 있습니다. 요구 사항에 따라 테이블 열의 데이터 유형을 선택할 수 있습니다.
SQL Server는 아래에 나열된 여섯 가지 범주의 데이터 유형을 제공합니다.
정확한 숫자 데이터 유형
| 데이터 형식 | 에서 | 에 |
|---|---|---|
| Bigint | -9,223,372,036,854,775,808 | 9,223,372,036,854,775,807 |
| int | -2,147,483,648 | 2,147,483,647 |
| smallint | -32,768 | 32,767 |
| 작은 | 0 | 255 |
| 비트 | 0 | 1 |
| 소수 | -10 ^ 38 +1 | 10 ^ 38 -1 |
| 숫자 | -10 ^ 38 +1 | 10 ^ 38 -1 |
| 돈 | -922,337,203,685,477.5808 | +922,337,203,685,477.5807 |
| 작은 돈 | -214,748.3648 | +214,748.3647 |
대략적인 숫자 데이터 유형
| 데이터 형식 | 에서 | 에 |
|---|---|---|
| 흙손 | -1.79E + 308 | 1.79E + 308 |
| 레알 | -3.40E + 38 | 3.40E + 38 |
날짜 및 시간 데이터 유형
| 데이터 형식 | 에서 | 에 |
|---|---|---|
| 날짜 시간 | 1753 년 1 월 1 일 | 9999 년 12 월 31 일 |
| smalldatetime | 1900 년 1 월 1 일 | 2079 년 6 월 6 일 |
| 데이트 | 1991 년 6 월 30 일과 같은 날짜를 저장합니다. | |
| 시각 | 오후 12:30과 같은 시간을 저장합니다. | |
Note − 여기서 datetime은 3.33 밀리 초의 정확도를 가지며 smalldatetime은 1 분의 정확도를가집니다.
문자열 데이터 유형
| Sr. 아니. | 데이터 유형 및 설명 |
|---|---|
| 1 | char 최대 8,000 자 (유니 코드가 아닌 고정 길이) |
| 2 | varchar 최대 8,000 자 (유니 코드가 아닌 가변 길이 데이터). |
| 삼 | varchar(max) 최대 길이 2E + 31 자, 가변 길이 비 유니 코드 데이터 (SQL Server 2005에만 해당). |
| 4 | text Variable-length non-Unicode data with a maximum length of 2,147,483,647 characters. |
Unicode Character Strings Data Types
| Sr.No. | DATA TYPE & Description |
|---|---|
| 1 | nchar Maximum length of 4,000 characters.( Fixed length Unicode) |
| 2 | nvarchar Maximum length of 4,000 characters.(Variable length Unicode) |
| 3 | nvarchar(max) Maximum length of 2E + 31 characters (SQL Server 2005 only).( Variable length Unicode) |
| 4 | ntext Maximum length of 1,073,741,823 characters. ( Variable length Unicode ) |
Binary Data Types
| Sr.No. | DATA TYPE & Description |
|---|---|
| 1 | binary Maximum length of 8,000 bytes(Fixed-length binary data ) |
| 2 | varbinary Maximum length of 8,000 bytes.(Variable length binary data) |
| 3 | varbinary(max) Maximum length of 2E + 31 bytes (SQL Server 2005 only). ( Variable length Binary data) |
| 4 | image Maximum length of 2,147,483,647 bytes. ( Variable length Binary Data) |
Misc Data Types
| Sr.No. | DATA TYPE & Description |
|---|---|
| 1 | sql_variant Stores values of various SQL Server-supported data types, except text, ntext, and timestamp. |
| 2 | timestamp Stores a database-wide unique number that gets updated every time a row gets updated |
| 3 | uniqueidentifier Stores a globally unique identifier (GUID) |
| 4 | xml Stores XML data. You can store xml instances in a column or a variable (SQL Server 2005 only). |
| 5 | cursor Reference to a cursor object |
| 6 | table Stores a result set for later processing |