Lab Manual 01 (Introduction)
Lab Manual 01 (Introduction)
Contents:
1. Database
2. SQL
3. Basic SQL Concepts
Database
A database is a systematic collection of data. They support electronic storage and
manipulation of data. Databases make data management easy.
Example #1
An online telephone directory uses a database to store data of people, phone numbers,
and other contact details. Your electricity service provider uses a database to manage
billing, client-related issues, handle fault data, etc.
Example #2
Facebook needs to store, manipulate, and present data related to members, their friends,
member activities, messages, advertisements, and a lot more. We can provide a countless
number of examples for the usage of databases.
SQL
SQL is the standard language for dealing with Relational Databases. SQL can be used to
insert, search, update, and delete database records. SQL can do lots of other operations,
including optimizing and maintenance of databases. SQL stands for Structured Query
language, pronounced as "S-Q-L" or sometimes as "See-Quel"... Relational databases like
MySQL Database, Oracle, MS SQL Server, Sybase, etc. use ANSI SQL.
1 OF 14
CL 2005 – Database Systems Lab Lab Manual - 01
Datatype From To
bit 0 1
tinyint 0 255
Datatype Description
DATETIME Stores date and time information in the format YYYY-MM-DD HH:MI:SS
2 OF 14
CL 2005 – Database Systems Lab Lab Manual - 01
Datatype Description
Note that all the above data types are for character stream, they should not be used with Unicode
data.
Datatype Description
NVARCHAR(
Variable-length storage with provided max characters
max)
3 OF 14
CL 2005 – Database Systems Lab Lab Manual - 01
<> Checks if the values of two operands are equal or not, if values are not equal then
condition becomes true.
> Checks if the value of left operand is greater than the value of right operand, if yes
then condition becomes true.
< Checks if the value of left operand is less than the value of right operand, if yes then
condition becomes true.
>= Checks if the value of left operand is greater than or equal to the value of right
operand, if yes then condition becomes true.
<= Checks if the value of left operand is less than or equal to the value of right
operand, if yes then condition becomes true.
4 OF 14
CL 2005 – Database Systems Lab Lab Manual - 01
Comparison operator:
● SELECT * FROM EMPLOYEES WHERE MANAGER_ID = 101;
● SELECT * FROM EMPLOYEES WHERE MANAGER_ID < 110;
● SELECT * FROM EMPLOYEES WHERE MANAGER_ID > 200;
● SELECT * FROM EMPLOYEES WHERE MANAGER_ID >= 200;
● SELECT * FROM EMPLOYEES WHERE MANAGER_ID <= 150;
● SELECT * FROM EMPLOYEES WHERE MANAGER_ID <> 114;
Logical Operators:
● SELECT FIRST_NAME,SALARY,JOB_ID,DEPARTMENT_ID FROM EMPLOYEES WHERE
JOB_ID = 'AD_VP' AND DEPARTMENT_ID = 90;
● SELECT FIRST_NAME,SALARY,JOB_ID,DEPARTMENT_ID FROM EMPLOYEES WHERE
JOB_ID = 'AD_VP' OR DEPARTMENT_ID = 90;
● SELECT FIRST_NAME,SALARY,JOB_ID,DEPARTMENT_ID FROM EMPLOYEES WHERE Not
JOB_ID = 'AD_VP';
5 OF 14