Database Reference
In-Depth Information
1. Character data types: Character data consist of any combination of letters, symbols, and
numeric characters.
a. CHAR : It is a ixed-length character data type.
Example: To specify the column, Street, and to have the CHAR data type with length
30, use
Street CHAR(30)
b. VARCHAR : It is a variable-length character data type.
Example: To specify the column, Description, and to have the VARCHAR data type
with the maximum length of 300, use
Description VARCHAR(300)
c. VARCHAR(MAX) : his data type allows you to deine a character data type with a
length up to 2 31 bytes of data.
he diference between the data type CHAR and the data type VARCHAR is that a
column speciied by CHAR may have many blank spaces if the data values do not ill up
the column width. he advantage of CHAR is that it runs faster when processing data
stored in a ixed-length column.
Corresponding to CHAR, VARCHAR, and VARCHAR(MAX), there are NCHAR,
NVARCHAR, and NVARCHAR(MAX) data types for Unicode characters. Unicode
characters are used for some special characters in languages such as Chinese and Japanese.
Each Unicode character takes two bytes. herefore, the lengths of NCHAR, NVARCHAR,
and NVARCHAR(MAX) are half of CHAR, VARCHAR, and VARCHAR(MAX).
2. Number data types: Number data types include integers and decimals.
a. INT : he INT data type consists of positive, zero, and negative whole numbers. he
range of INT is from -2,147,483,648 to 2,147,483,647.
Example: Integers can be used as the data type for a key column. In the following, we
specify the primary key column ClassID with the INT data type:
ClassID INT PRIMARY KEY
b. DECIMAL (or NUMERIC) : he DECIMAL data type includes positive and negative
decimal numbers. he values of DECIMAL data are from 10^38 + 1 through 10^38 1.
Example: he following statement speciies the column GPA with the DECIMAL data type:
GPA DECIM A L
3. Date and Time data type: It represents date and time values.
a. DATETIME : his data type speciies a column to contain date and time values from
1-1-1753 to 12-31-9999.
Example: To deine the column ExpirationDate to have date and time values, use
ExpirationDate DATETIME
4. Monetary data type: It represents amounts of money.
a. MONEY : his data type speciies a column to contain money values.
Example: To deine the money data type for the column Price, use
Price MONEY
More data types are supported by Windows Azure SQL Database.
Search WWH ::




Custom Search