Wednesday 20 February 2013

SQL Operators & DataTypes


SQL Operators

Like many other Computer Languages, SQL also has operators. Operators are symbols or word that Performa action. For example = is an operator for assigning value. Some of the mostly used SQL operators are given here

EQUAL                                                  =
NOT EQUAL                                        <>
GRATER                                                >
LESSER                                                  <
LESSER or EQUAL                              <=
GRATER or EQUAL                           >=
OR                                                          or
AND                                                       and
BETWEEN                                            between

SQL Datatypes Tutorial

SQL Data Type defines the type of Data that is going to be stored in a column. Most of the RDBMS will define use their own data types. So you may not find all data types of MS SQL server in MySQL or Vice Versa.


SQL Server provides a large number of data types that allows further data manipulation. There are four main groups:

1.       Numbers:

Type
From
To
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
tinyint
0
255
bit
0
1
decimal
-1038 +1
1038 –1
numeric
-1038 +1
1038 –1
money
-922,337,203,685,477.5808
+922,337,203,685,477.5807
smallmoney
-214,748.3648
+214,748.3647

2.       Date:

Type
From
To
Datetime
Jan 1, 1753
Dec 31, 9999
smalldatetime
Jan 1, 1900
Jun 6, 2079

3.       Characters:

Type
Description
char
Fixed-length non-Unicode character data with a maximum length of 8,000 characters.
varchar
Variable-length non-Unicode data with a maximum of 8,000 characters.
text
Variable-length non-Unicode data with a maximum length of 2,147,483,647 characters.
nchar
Fixed-length Unicode data with a maximum length of 4,000 characters. Wide characters support ( e.g. Chinese, Arabic, etc)
nvarchar
Variable-length Unicode data with a maximum length of 4,000 characters. ( e.g. Chinese, Arabic, etc)
ntext
Variable-length Unicode data with a maximum length of 1,073,741,823 characters. ( e.g. Chinese, Arabic, etc)

4.       Binary:

Type
Description
binary
Fixed-length binary data with a maximum length of 8,000 bytes.
varbinary
Variable-length binary data. Maximum length 8,000 bytes.
image
Variable-length binary data. Maximum length 2,147,483,647 bytes.

No comments:

Post a Comment