Structured Query Language
Structured Query Language
Introduction
SQL, Structured Query Languages, was developed in 1970’s in IBM
Laboratory. It is used for accessing and manipulating databases. SQL
commands are used to create, transform and retrieve information
from Relational Database Management System and are also used for to
create interface between a user and database. By using SQL
commands, one can search for any data in the database and perform
other functions like creating, adding records, modifying data, removing
rows, dropping tables etc.
Features of SQL
It can retrieve data from a database through Query processing
It can insert records in a database.
It can update records in a database.
It can create a new database and modify the existing ones.
It can create new tables in database.
It can create view in database.
SQL statements
Dat
Date and Time
a
(DATE, TIME
Typ
Numeric
es
(INT, FLOAT)
)
String/Text
(CHAR, VARCHAR )
stores exactly as you specify it. i.e., no blanks are added if the length is
shorter than maximum length n, then an error message is displayed.
CHAR VARCHAR
1.CHAR data type provides fixed 1.VARCHAR data type provides
length memory storage. variable length memory storage.
2. The CHAR data type can store a 2.The VARCHAR data type can
maximum of 0 to 255 characters. store a maximum number up to
65,535
3. CHAR data type is used when 3.VARCHAR data types is used
the data entries in a column are when the data entries in a column
expected to be of the same size. are expected to vary considerably
in size.
4.CHAR(n) will take n characters 4.VARCHAR(n) will take only the
of storage even if you enter less required storage for the actual
than n characters to that column. number of characters entered to
that column.
5. If a value entered is shorter 5.No blanks are added if the
than its length x, then blanks are length is shorter than the
added. maximum length, n.
6. CHAR data type takes memory 6.VARCHAR takes up memory
space of 1 byte per character. space of 1 byte per character, +2
bytes to hold variable length
information.
7.Seacrh operation is faster is 7. Search operation works slower
with CHAR data type column. in VARCHAR data type column as
compared to CHAR type
8.Example, name char(10); 8.Example, name varchar(10);
Name=”Amit”; Name=”Amit”;