SQL Server Data Type Details

xiaoxiao2021-04-04  238

Five data types in SQL

Http://3easp.com/Article/211/241/2006/04/03/200604034867.SHTML

SQL Server data type

Http://bbs.sz.js.cn/dispbbs.asp?boardid=53&id=173887

SQL Server Data Type Details

http://www.mbsky.com/infowview/Article_3578.html

type of data

Types of

Describe

Bit

Integrity

The Bit data type is integer, its value can only be 0, 1 or null. This data type is used to store data with only two possible values, such as Yes or NO, TRUE, or FA LSE, ON or OFF

int

Integrity

The INT data type can be stored between-231 (-2147483648) to 231 (2147483 647). Almost all numerical data stored in the database can be used in this data type. This type of data occupies 4 bytes in the database

Smallint

Integrity

The Smallint data type can store an integer from-215 (-32768) to 215 (32767). This data type is very useful to store some of the numerical data that is often defined within a specific range. This type of data occupies 2 bytes space in the database

Tinyint

Integrity

The Tinyint data type can store an integer from 0 to 255. It is useful when you only intend to store a limited number of values. This type of data occupies 1 byte in the database

Numeric

Accurate numerical type

NUMERIC data type is the same as Decimal

Decimal

Accurate numerical type

The DECIMAL data type can be used to store numerical data from the fixed accuracy and range of -1038-1 to 1038-1. When using this data type, the range and accuracy must be specified. The range is the total number of numbers that can be stored around the decimal point. Accuracy is the number of digits stored on the right side of the decimal point

Money

Monetary type

The Money data type is used to represent money and currency values. This type of data can store data from -9222 billion to 92.22 billion, accurate to one in the currency unit.

Smallmoney

Monetary type

The SmallMoney data type is used to represent money and currency values. This data type can store data between -214748.3648 to 214748.3647, accurate to one in the currency unit

Float

Approximate numerical type

The Float data type is an approximate numeric type with a number of floating points. Say that the floating point is approximate, because it is not all the numbers within its range. The floating point number can be any number between -1.79e 308 to 1.79e 308

REAL

Approximate numerical type

The REAL data type is like a floating point, is an approximate numerical type. It can represent the number of floating point between -3.40E 38 to 3.40e 38

Datetime

Date time

The DateTime data type is used to represent the date and time. This data type is stored from January 1, 1753 to December 3, 9999, all date and time data, accurate to three hundred-thousand seconds or 3.33 milliseconds

SmallDateTime

Date time

The SmallDateTime data type is used to represent the date and time from January 1, 2079, June 6, 2079, accurate to one minute

Cursor

Special data type

The CURSOR data type is a special data type that contains a reference to the cursor. This type of data is used in the stored procedure and cannot be used when you create a table.

Timestamp

Special data type

The TimeSTAMP data type is a special data type to create a unique number of databases within a database. There can only be a TIMESTAMP column in a table. The value of the TimeStAMP column changes each time you insert or modify a row. Although there is "Time" in its name, the TimeStAMP column is not a date that people can recognize. In a database, the TimeStamp value is unique.

UniqueIdentifier

Special data type

The UNIQUEIDENTIFIER data type is used to store a global unique identifier, that is, GUID. GUID is indeed a global unique. This number has little opportunities to be rebuilt in another system. You can use the NewID function or convert a string as a unique identifier to initialize the column char.

Character pattern

The CHAR data type is used to store data for a fixed length of the specified length non-unified encoding. When defined as this type, you must specify the column. This data type is useful when you always know the length of the data to be stored. For example, when you add 4 character formats in Postal Codes, you know that you will always use 10 characters. The column width of this data type is 8000 characters.

VARCHAR

Character pattern

VARCHAR data type, like a CHAR type, used to store non-uniform encoded character data. Different than the CHAR type, this data type is growing. When defined as the data type, you want to specify the maximum length of the column. It is the biggest difference with the CHAR data type, the length of the store is not a column, but the length of the data.

TEXT

Character pattern

The TEXT data type is used to store a large number of non-uniform encoded character data. This type of data can have up to 231-1 or 2 billion characters.

nchar

Unified encoded characters

NCHAR data types are used to store fixed-length unified encoding characters. Unified encoding uses a double-byte structure to store each character, not the single-byte (the case in normal text). It allows a lot of extended characters. This data type can store 4000 characters, and double the byte space used.

nvarchar

Unified encoded characters

NVARCHAR data types are used as unified unified encoded characteristics. This data type can store 4000 characters, and the byte space used is doubled.

NText

Unified encoded characters

NTEXT data types are used to store large amounts of unified encoded character data. This type of data can store 230 -1 or nearly 1 billion characters, and the useful byte space is doubled.

binary

Binary data type

The binary data type is used to store binary data that can reach 8,000 bytes long. When the content of the input table is close to the same length, you should use this type of data type

Varbinary

Binary data type

The Varbinary data type is used to store binary data that can reach 8,000 bytes long. When the content of the input table varies, you should use this data type

Image

Binary data type

Image data types are used to store growth binary data, up to 231-1 or about 2 billion bytes