0% found this document useful (0 votes)
11 views

DBMS Lab File-BCA-507P

Uploaded by

bk401094
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

DBMS Lab File-BCA-507P

Uploaded by

bk401094
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

MANGALMAY INSTITUTE OF

MANAGEMENT & TECHNOLOGY,


Gr. NOIDA

DBMS LAB FILE (BCA-507-P)


Session: 2024-25
5th SEMESTER

SUBMITTED BY:
Name: ____________________
Roll No. ___________________
BACHELOR OF COMPUTER APPLICATION

SUBMITTED TO:
Mr. KRISHNA KUMAR
Assistant Professor
Department of Computer Application
Sign: ___________________
`

INDEX

Sr. No Experiment Date Sign.


LAB EXERCISE #1 - CREATING TABLES

1.1 Objective 1.2 Theory 1.3 Assignments

1.1 OBJECTIVE: Writing simple queries in SQL

1.2 THEORY & CONCEPTS: SQL (Structured Query Language) is a nonprocedural language,
you specify what you want, not how to get it. A block structured format of English key words is
used in this query language. It has the following components.

DDL (Data Definition Language): The SQL DDL provides command for defining relation
schemas, deleting relations and modifying relation schema.

DML (DATA Manipulation Language): It includes commands to insert tuples into, delete tuples
from and modify tuples in the database.

View definition: The SQL DDL includes commands for defining views. Transaction Control- SQL
includes for specifying the beginning and ending of transactions.

Embedded SQL and Dynamic SQL: Embedded and Dynamic SQL define how SQL statements
can be embedded with in general purpose programming languages, such as C, C++, JAVA,
COBOL, Pascal and Fortran.

Integrity: The SQL DDL includes commands for specifying integrity constraints that the data
stored in the database must specify. Updates that violate integrity constraints are allowed.

Authorization: The SQL DDL includes commands for specifying access rights to relations and
views.

Domain types in SQL: The SQL standard supports a variety of built in domain types, including:
 Char (n)- A fixed length character length string with user specified length .
 Varchar (n)- A variable character length string with user specified maximum length n.
 Int- An integer.
 Small integer- A small integer.
 Numeric (p, d)-A Fixed point number with user defined precision.
 Real, double precision- Floating point and double precision floating point numbers with
machine dependent precision.
 Float (n)- A floating point number, with precision of at least n digits.
 Date- A calendar date containing a (four digit) year, month and day of the month.
 Time- The time of day, in hours, minutes and seconds e.g. Time ’09:30:00’.
 Number- Number is used to store numbers (fixed or floating point).

CHAR(<size>): datatype is fixed-length alphanumeric string, which has a maximum length in


bytes. Its size can range from a minimum of 1 byte to a maximum of 2000 bytes. The default is 1.

VARCHAR2(<size>): datatype is a variable-length alphanumeric string, which has a maximum


length in bytes. VARCHAR2 columns require only the amount of space needed to store the data
and can store upto 4000 bytes. There is no default size for the varchar2 data type.

NUMBER(<p>, <s>): datatype stores numbers with a precision of p digits and a scale of s digits.
The precision and scale values are optional. The precision can be between 1 and 38, and the scale
DBMS Lab (BCA-507(P))
has range between -82 and 127.

DATE: datatype is used to store date and time information, the DATE datatype occupies a storage
space between seven bytes. The following information is contained within each DATE datatype:
 Century
 Year
 Month
 Day
 Hour
 Minute
 Second
The default format is DD-MON-YY. The SYSDATE function returns the current system date and
time from the database server to which you’re currently connected.

Operators:
Arithmetic Operators: +, -, *, /
Concatenation Operators: ||
Set Operators:
 UNION: returns all rows from either queries; no duplicate rows
 UNION ALL: returns all rows from either queries; including duplicates
 INTERSECT: returns distinct rows that are returned by both queries
 MINUS: returns distinct rows that are returned by the first query but not returned by the
second
Comparison Operators:
 = (Equality)
 !=, <>, or ^= (Inequality)
 < (Less Than)
 > (More Than)
 <= (Less Than or Equal To)
 >= (Greater Than or Equal To)
ANY or SOME: operators are used to compare a value to each value in a list or subquery. These
operators must be preceeded by the comparison operators.
ALL: operator is used to compare a value to every value in a list or subquery. These operators must
be preceeded by the comparison operators.
Logical Operators: NOT, AND, OR

Writing Simple Queries: A query is a request for information from the database tables. Simple
queries are those that retrieve data from a single table. The basis of a query is the SELECT
statement.
Using the SELECT statement:
Syntax:
SELECT <columnname1>,…., <columnname n>

FROM <tablename>;

Column Alias Names: Column alias name is defined next to the column name with a space or by
Sing the keyord AS.
Syntax:
SELECT <columnname1> AS <aliasname1>, ….,<columnname n> AS <aliasname n>
FROM <tablename>;

Elimination of duplicates from the select statement-


Syntax-
DBMS Lab (BCA-507(P))
SELECT DISTINCT columnname, columnname
FROM tablename;

Limiting Rows: A WHERE clause is used in SELECT statement to limit number of rows
processed.
Syntax-
SELECT <columnname1>,….,<columnname n>
FROM <tablename>
WHERE <searchcondition>;

Sorting Rows: ORDER BY clause is used to sort the rows in the resultset in ascending or
descending order. The default order is ascending.
Syntax:
For ascending order:
SELECT <columnname1>,….,<columnname n>
FROM <tablename>
WHERE <searchcondition>
ORDER BY <columnname>;

For descending order:


SELECT <columnname1>,….,<columnname n>
FROM <tablename>
WHERE <searchcondition>
ORDER BY <columnname> DESC;

Other Operators:
IN and NOT IN: the IN and NOT In operators are used to test a membership condition. IN
evaluates to true if the value exists in the list or the resultset from the subquery. The NOT
IN evaluates to true if the value does not exist in the list or the resultset from a subquery.

BETWEEN: operator is used to test a range. BETWEEN A AND B evaluates to true if the
value is greater than or equal to A and less than or equal to B.

LIKE: operator is used to perform pattern matching. The pattern search character % is used
to match any character and any number of characters. _ is used to match any single
character. To search for the actual character % in the pattern search, you should include an
escape character (/) in the search string and notify using ESCAPE clause.

1.3 ASSIGNMENTS

Assignment 1

Following tables are created:


i) emp

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO


7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
DBMS Lab (BCA-507(P))
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-81 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-81 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10

ii) dept
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

On the basis of above two tables answer the following queries:


1. Display all records of emp table.
2. Display all records of dept table.
3. Display the names of all employees and their manager’s no. with headers “Employee
Name” and “Manager” respectively.
4. Calculate and display the quarterly salary of all employees.
5. List all employees where manager is “7689”.
6. Display the names of all employees who earn commission greater than or equal to 0.
7. Display the employee name and the department name where salary is greater than 1000.
8. Display all records from dept table where department no. is either less than 30 or less than
40.

DBMS Lab (BCA-507(P))


Assignment 2

On the basis of above two tables answer the following queries:

1. Display all records from dept table where department no. is less than 30 or 40.
2. List all employees working as clerks and with salary greater than or equal to 1000.
3. List the names and department no. of all employees who do not belong to department no.
30 and 40.
4. List the names and department no. of all employees who belong to department no. 10 and
30.
5. List the names and department no. of all employees whose salary is greater than 1000 and
less than 2000.
6. List all employees with names starting with “A”.
7. Display all records from emp table in descending order of the salary of the employees.

DBMS Lab (BCA-507(P))


LAB EXERCISE #2 - SINGLE ROW FUNCTIONS

1.1 Objective 1.2 Theory 1.3 Assignment

1.1 OBJECTIVE: Perform various single row functions.

1.2 THEORY AND CONCEPTS: There are many types of single-row functions built into SQL.
These include character, numeric, date, etc. All single-row functions can be incorporated into SQL.
These can be used in the SELECT, WHERE, and ORDER BY clauses of SELECT statements.

Single-row character functions: operate on character data. These are as follows:


Function Description
ASCII Returns the ASCII decimal equivalent of a
character.
CHR Returns the character given the decimal
equivalent
CONCAT Concatenates two strings
INITCAP Returns the string with the first letter of each
word in uppercase
LENGTH Returns the length of a string in characters
LOWER Converts a string to all lowercase
SUBSTR Returns a section of the specified string
UPPER Converts a string to all uppercase

Single-row numeric functions: operate on numeric data. These are as follows:


Function Description
ABS Returns the absolute value
CEIL Returns the next higher integer
COS Returns the cosine
EXP Returns the base of natural logarithms raised to
a power
FLOOR Returns the next smaller integer
LN Returns the natural logarithm
LOG Returns the logarithm
MOD Returns the modulo of a division operation
POWER Returns a number raised to an arbitrary power
ROUND Rounds a number
SIGN Returns an indicator of sign
SIN Returns the sine
SQRT Returns the square root of a number
TAN Returns the tangent

Signle-row date dunctions: operate in DATE datatypes. These are as follows:


Function Description
ADD_MONTHS Adds a number of months to a date
CURRENT_DATE Returns the current date
CURRENT_TIMESTAMP Returns the current date and time in a
TIMESTAMP datatype
LAST_DAY Returns the last day of a month
LOCAL_TIMESTAMP Returns the current date and time in the session
DBMS Lab (BCA-507(P))
time zone
MONTHS_BETWEEN Returns the number of months between two
dates
NEXT_DAY Returns the next day of a week following a
given date
SYSDATE Returns the current date/time

1.3 ASSIGNMENTS

Assignment 3

Using the table dual answer the following queries.


1. Calculate the ASCII value of A and z.
2. Calculate the character equivalent of 65 and 122.
3. Concatenate the strings “Welcome”, “to SQL”.
4. Display the following string with first letter of each word in uppercase: “the three
musketeers”.
5. Calculate the length of the string “the three musketeers”.
6. Display the string “the three musketeers” in all lowercase.
7. Display the string “the three musketeers” in all uppercase.
8. Display the word SQL from the string “Welcome to SQL”.

DBMS Lab (BCA-507(P))


Assignment 4

Using the table dual answer the following queries.

1. Calculate the absolute value of -52.


2. Calculate the next higher integer following: 9.8, -32.85.
3. Calculate the cosine of -3.14159.
4. Calculate the next smaller integer following: 9.8, -32.85.
5. Calculate the natural logarithm of 2.7.
6. Calculate the logarithm of 64 to the base 8.
7. Calculate the modulous of 14 by 5.
8. Calculate 2 raised to the power 10.
9. Calculate the rounded figure of 2245.55 and -20.89.

DBMS Lab (BCA-507(P))


Assignment 5

Using the table dual answer the following queries.

1. Calculate the sign of -2.3, 0, and 47.


2. Calculate the sine of 1.57079.
3. Calculate the square root of 64, 49, and 5.
4. Calculate the tangent of 1.57079.
5. Add 3 months to the current system date.
6. Display the current date and system date.
7. Calculate the months between 19-Dec-2002 and 19-Mar-2003.

DBMS Lab (BCA-507(P))


LAB EXERCISE #3 - AGGREGATING DATA AND GROUP FUNCTIONS

1.1 Objective 1.2 Theory 1.3 Assignment

1.1 OBJECTIVE: To perform various group functions

1.2 THEORY AND CONCEPTS: Group functions differ from single-row functions in how they
are evaluated. Single-row functions are evaluated once for each row retrieved. Group functions are
evaluated on groups of one or more rows at a time. Group functions are sometimes called aggregate
functions and return a value based on a number of inputs. The exact number of inputs are not
determined until the query is executed and all rows are fetched. This differs from single-row
functions in which the number of inputs is knows at parse time-before the query is executed. These
are as follows:

Function Description
AVG Returns the statistical mean
COUNT Returns the number of non-NULL rows
MAX Returns the largest value
MIN Returns the smallest value
SUM Adds all values and returns the result

Grouping date with GROUP BY: Group functions work on data that is grouped. We tell the
database how to group or categorize data with a GROUP BY clause. Whenever we use a group
function in SELECT clause of a SELECT statement, we must place all non-grouping/non-constant
columns in the GROUP BY clause. If no GROUP BY clause id specified, the default grouping
becomes the entire result set.

Syntax:
SELECT <columnname1>,….,<columnname n>, <aggregate function(columnname)>
FROM <tablename>
GROUP BY <columnname>;

Limiting grouped data with HAVING: Group functions cannot be used in WHERE clause.
Grouping is done after all rows have been fetched.

Syntax:
SELECT <columnname1>,….,<columnname n>, <aggregate function(columnname)>
FROM <tablename>
GROUP BY <columnname>
HAVING <condition>;

DBMS Lab (BCA-507(P))


1.3 ASSIGNMENTS:

Assignment 6
Following table is created:
emp

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO


7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-81 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-81 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10

On the basis of above table answer the following queries:

1. Calculate the average salary of all employees.


2. Calculate the total salary of all employees.
3. Find the name of the employee who is given the maximum salary.
4. Find the name of the employee who is given the minimum salary.
5. Calculate the department wise total salary of employees.

DBMS Lab (BCA-507(P))


Assignment 7
Following table is created:
emp

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO


7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-81 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-81 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10

1. Calculate the maximum, minimum, and average salary given to each department.
2. Display the total salary given to various designations in the organization.
3. Display the total number of employees working on different designations in the
organization.
4. Display the department numbers where the employees have average salary greater
than 2000.
5. Display the names of all employees belonging to department’s having average
salary greater than 2000.

DBMS Lab (BCA-507(P))


LAB EXERCISE #4 - MANAGING TABLES AND CONSTRAINTS.

1.1 Objective 1.2 Theory 1.3 Assignment

1.1 OBJECTIVE: Managing tables and applying constraints on columns.

1.2 THEORY AND CONCEPTS: A table is the main database object. A table is defines with
columns and stores rows of data. A table should have atleast one column.

Creating tables:
Syntax:
CREATE TABLE <table name>
( <columnname1> datatype(size),
….
<columnname n> datatype(size)
);

Specifying default values for columns:


CREATE TABLE <table name>
( <columnname1> datatype(size),
….
<columnname n> datatype(size) DEFAULT ‘value’
);

Inserting data into the table:


Syntax
INSERT INTO <table name> (<columnname(s)>) VALUES
(‘value1’,….,’value n’);

Creating a table from another table:


Syntax
CREATE TABLE <table name>
AS SELECT <columnname1>,….,<columnsname n> FROM <table name>;

Describing a table:
Syntax
DESCRIBE <table name> or DESC <table name>

Adding columns:
Syntax
ALTER TABLE <table name> ADD <columnname> <datatype(size)>;

Modifying columns:
Syntax
ALTER TABLE <table name> MODIFY (<columnname> <new datatype(size)>);

Updating tables:
Syntax
UPDATE TABLE <table name> SET <columnname>=’value’
WHERE <condition>;

DBMS Lab (BCA-507(P))


Dropping columns:
Syntax
ALTER TABLE <table name> DROP COLUMN(<columnname>);

Dropping tables:
Syntax
DROP TABLE <table name>;

Renaming tables:
Syntax
RENAME <old table name> TO <new table name>;

Creating constraints: Integrity constraints prevent bad data from being entered into the
database. These constraints can be specified at the column level or at the table level by
CREATE TABLE or ALTER TABLE command. These are as follows:
NOT NULL: prevents NULL values from being entered into the column. It is defined at the
column level. It cannot be defined at the table level.
Syntax
CREATE TABLE <table name>
(<columnname> <datatype(size)> CONSTRAINT <constraint name > NOT NULL);
Or
ALTER TABLE <table name> MODIFY <columnname> NOT NULL;

CHECK: constraint can be defined at the column level as well at the table level. The
condition specified in the CHECK clause should evaluate to a Boolean result and can refer
to values in other columns of the same row; the condition cannot use queries.
Syntax
CREATE TABLE <table name>
(<columnname> <datatype(size)>,
CONSTRAINT CHECK <constraint name> (<condition>));
or
ALTER TABLE <table name> ADD CONSTRAINT <constraint name> CHECK
(<condition>);

UNIQUE: constraint protects one or more columns in a table, ensuring that no two rows
contain duplicate data in the protected columns. It can be specified at the column level as
wella s at the table level.
Syntax
Columns level: CONSTRAINT <constraint name> UNIQUE
Table level: CONSTRAINT <constraint name>
UNIQUE(<columnname1>,….,<columnname n>);
Or
ALTER TABLE <table name> ADD CONSTRAINT <constraint name>
UNIQUE(<columnname1>,….,<columnname n>);

PRIMARY KEY: All characteristics of the unique key are applicable to the primary key
constraint, except the NULL values are not allowed in the primary key columns. A table
can have only one primary key.
Syntax
DBMS Lab (BCA-507(P))
Column level: CONSTRAINT <constraint name> PRIMARY KEY
Table level: CONSTRAINT <constraint name>
PRIMARY KEY (<columnname1>,….,<columnname n>);
Or
ALTER TABLE <table name> ADD CONSTRAINT <constraint name> PRIMARY KEY
(<columnname1>,….,<columnname n>);

FOREIGN KEY: constraint protects one or more columns in a table by ensuring that for
each non-NULL value there is data available elsewhere in the database with a primary or
unique key.
Syntax
Column level: CONSTRAINT <constraint name> REERENCES <table
name>(<columnname1>,….,<columnname n>);
Table level: CONSTRAINT <constraint name>
FOREIGN KEY (<columnname1>,….,<columnname n>)
REERENCES <table name>(<columnname1>,….,<columnname n>);
Or
ALTER TABLE <table name> ADD CONSTRAINT <constraint name>
FOREIGN KEY (<columnname1>,….,<columnname n>)
REERENCES <table name>(<columnname1>,….,<columnname n>);

Dropping constraints:
Syntax
ALTER TABLE <table name> DROP <constraint name>

ASSIGNMENTS:

Assignment 8
Que 1. Create the following tables:
Student
Column Name Data Type Size Constraint(s)
Rollno Number 10 Primary Key
Sname Varchar2 30 Not Null
Status Varchar2 10 Reg/Ex/Readmitted
Sem Number 1 Not Null
DateofReg Date Not Null
Rank Number 10 Unique
Scholarship Number 10 --
BranchNo Varchar2 5 Foreign Key

Department
Column Name Data Type Size Constraint(s)
BranchNo Varchar2 5 Primary Key
BranchName Varchar2 30 Not Null
HOD Varchar2 30 Not Null

DBMS Lab (BCA-507(P))


Q2. Insert the following values into the challan header and challan_details tables:

Student

Rollno Sname Status Sem DateofReg Rank Scholarship BranchNo


0802810001 Henry Reg 1 10-Jul-09 10000 10
0802810010 Peter Reg 1 10-Jul-09 1500 10
0802811014 Nichole Reg 2 12-Jul-09 100 50000 11
0802811020 Michael Ex 2 14-Aug-09 2000 11
0802811025 Suzanne Reg 3 14-Aug-09 1000 11
0802811040 Harry Reg 4 30-Aug-08 200 30000 11
0802812010 Jones Reg 5 12-Jul-08 400 12
0802812014 Sarah Ex 6 17-Jul-09 12000 12
0802812028 Rose Reg 2 17-Aug-09 7000 12
0802813041 Stella Readmitted 4 31-Jul-09 8000 13
0802814004 Smith Readmitted 1 04-Aug-09 800 14
0802814027 Samuel Reg 5 07-Aug-09 80 650000 14
0802814017 Ceaser Reg 4 16-Jul-09 8 80000 14
0802814008 Charlie Reg 4 17-Jul-09 10 70000 14

Branch

BranchNo BranchName HOD


10 Computer Clark
Science
11 Information John
Technology
12 Electronics Brad
13 Electrical King
14 MCA Andrew

Answer the following queries

Q1. Make the primary key to client_no in client_master.


Q2. Add a new column phone_no in the client_master table.
Q3. Add the not null constraint in the product_master table with the columns description, profit
percent , sell price and cost price.
Q4. Change the size of client_no field in the client_master table.
Q5. Select product_no, description where profit percent is between 20 and 30 both inclusive.

DBMS Lab (BCA-507(P))


LAB EXERCISE #5 - USE OF JOINS.

1.1 Objective 1.2 Theory 1.3 Assignment 1.4. Solution to Assignment

1.1 OBJECTIVE: How different types of join is used.

1.2 THEORY AND CONCEPTS: Joint Multiple Table (Equi Join): Sometimes we require to
treat more than one table as though manipulate data from all the tables as though the tables were not
separate object but one single entity. To achieve this we have to join tables. Tables are joined on
column that has dame data type and data with in tables.

The tables that have to be joined are specified in the FROM clause and the joining
attributes in the WHERE clause.

Algorithm for JOIN in SQL:


1. Cartesian product of tables (specified in the FROM clause)
2. Selection of rows that match (predicate in the WHERE clause)
3. Project column specified in the SELECT clause.

1. Cartesian product:-

Consider two table student and course


Select B.*,P.*
FROM student B, course P;

2. INNER JOIN:
Cartesian product followed by selection
Select B.*,P.*
FROM student B, Course P
WHERE B.course # P.course # ;

3. LEFT OUTER JOIN:

LEFT OUTER JOIN = Cartesian product + selection but include rows from the left
table which are unmatched pat nulls in the values of attributes belonging to th e second
table
Exam:

Select B.*,P*
FROM student B left join course p
ON B.course # P.course #;

4. RIGHT OUTER JOIN:


RIGHT OUTER JOIN = Cartesian product + selection but include rows from right table
which are unmatched

Exam:
Select B.*,P.*
From student B RIGHT JOIN course P
B.course# = P course # ;

DBMS Lab (BCA-507(P))


5. FULL OUTER JOIN
Exam
Select B.*,P.*
From student B FULL JOIN course P
On B.course # = P course # ;

1.3 ASSIGNMENTS

Assignment 9

1. Find out the product which has been sold to ‘Ivan Sayross.’
2. Find out the product and their quantities that will have do delivered.
3. Find the product no and description of moving products.
4. Find out the names of clients who have purchased ‘CD DRIVE’
5. List the product_no and s_order_no of customers haaving qty ordered less than 5 from the
order details table for the product “1.44 floppies”.

DBMS Lab (BCA-507(P))


Assignment 10

1. Find the products and their quantities for the orders placed by ‘Vandan Saitwal ’ and “Ivan
Bayross”.
2. Find the products and their quantities for the orders placed by client_no “ C00001” and
“C00002”
3. Find the order No,, Client No and salesman No. where a client has been received by more
than one salesman.
4. Display the s_order_date in the format “dd-mm-yy” e.g. “12- feb-96”
5. Find the date , 15 days after date.

DBMS Lab (BCA-507(P))

You might also like