SQL Server provides data type synonyms for ISO compatibility
числа с фиксированной точкой
decimal
The default precision is 18 (m)
numeric(m,n)
m - число символов в числе, включая точку
n - число знаков после запятой
m не превосходит 37 (38)
The decimal and numeric data types are identical
целые числа (в порядке роста диапозона доступных значений)
bigint
int
smallint
tinyint
bit
Числа с плавающей точкой
real
всегда 4 байта
float[(n)]
n - число бит под мантиссу. По умолчанию 53. Может принимать значение от 1 до 53
| n value | Precision | Storage size |
|---|---|---|
| 1-24 | 7 digits | 4 bytes |
| 25-53 | 15 digits | 8 bytes |
The synonym for double precision is float(53)
Строковые
char(n)
nchar(n)
varchar(n)
nvarchar(n)
text
ntext
varchar(max)
nvarchar(max)
Денежные
money
числа до 4 знаков после запятой
You don’t need to enclose currency or monetary data in single quotation marks ('). While you can specify monetary values preceded by a currency symbol, SQL Server doesn’t store any currency information associated with the symbol, it only stores the numeric value
smallmoney
Даты и время
date
time
datetime
datetime2
smalldatetime
datetimeoffset
Бинарные
binary(n)
фиксированной длины до 8000 байт
varbinary(n)
переменной длины до 8000 байт (размер + указатель (2 байта))
varbinary(max)
max indicates that the maximum storage size is 2^31-1 bytes.
image
Variable-length binary data from 0 through 2^31-1 (2,147,483,647) bytes.
Другие типы данных
- cursor
- geography 1
- geometry 1
- hierarchyid
- json
- vector
- rowversion
- sql_variant
- table
- uniqueidentifier
- xml Иерархические типы данных могут хорошо индексироваться. Если нужен быстрый поиск по иерархической структуре, имеет смысл использовать его Можно создавать свои типы