Lab Course File: Galgotias University
Lab Course File: Galgotias University
Lab Course File: Galgotias University
BCA
B070303P
LIST OF EXPERIMENTS
Sr.
Title of Lab Experiments
No.
1. 1) Implement Data Definition language Statements.
5)Implement SINGLE ROW functions (Character, Numeric, Date functions) and GROUP functions
5. (avg, count, max, min, sum).
8. 8)Implement the concept of Data Control Language (DCL), Transaction Control Language(TCL).
10. 10Create a Database for Banking Sector and implement various queries on it.
11. 11 Create a Database for Customer Sale/purchase and implement various queries on it
EXPERIMENT DETAILS
Experiment 1
Title Data Definition Language
Study of Data Definition language commands. - Create table, Alter Table, Drop Table,
Objective
Rename Table.
Pre-
Knowledge of Basic Database
requisite
The SQL DDL allows specification of not only a set of relations but also information
about each relation, including-
CREATE TABLE
ALTER TABLE
DROP TABLE
RENAME TABLE
TRUNCATE
Post Lab
Assignment
(If Any)
OUTPUT:
CREATE TABLE
desc HIMANSHU
desc HIMANSHU
ALTER MODIFY FIELD DATA SIZE
desc HIMANSHU
desc HIMANSHU
desc HIMANSHU
TRUNCATE
desc HIMANSHU
RENAME TABLE
desc RISHABH
DROP TABLE
desc RISHABH
Experiment 2
Title Data Manipulation Language Statements.
Pre- Knowledge of
requisite ORACLE Queries
Data Manipulation Language (DML) statements are used for managing data in
database. DML commands are not auto-committed. It means changes made by DML
command are not permanent to database, it can be rolled back.
DML statements are used for managing data within schema objects. Some examples:
Algorithm
o SELECT - retrieve data from the a database
/Theory
o INSERT - insert data into a table
o DELETE - deletes all records from a table, the space for the records remain
Post Lab
Assignment
(If Any)
OUTPUT:
INSERT
UPDATE
DELETE
Pre- Knowledge of
requisite ORACLE
The most commonly used SQL command is SELECT statement. SQL SELECT
Algorithm statement is used to query or retrieve data from a table in the database. A query may
/Theory retrieve information from specified columns or from all of the columns in the table.
To create a simple SQL SELECT Statement, you must specify the column(s) name
and the table name. The whole query is called SQL SELECT Statement.
Post Lab
Assignment
(If Any)
OUTPUT:
Experiment 4
Title Keys
Pre- Knowledge of
requisite ORACLE COMMANDS
SQL Constraints
SQL constraints are used to specify rules for the data in a table.
If there is any violation between the constraint and the data action, the action is
aborted by the constraint.
Constraints can be specified when the table is created (inside the CREATE TABLE
statement) or after the table is created (inside the ALTER TABLE statement).
UNIQUE - Ensures that each row for a column must have a unique value
Algorithm PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Ensures
/Theory that a column (or combination of two or more columns) have a unique identity
which helps to find a particular record in a table more easily and quickly
FOREIGN KEY - Ensure the referential integrity of the data in one table to
match values in another table
The PRIMARY KEY constraint uniquely identifies each record in a database table.
Post Lab
Assignment
(If Any)
OUTPUT
Experiment 5
Title Single Row functions and Group functions
Study of single row functions (Character, Numeric, Date functions) and group functions
Objective
(avg, count, max, min, sum).
Pre- Knowledge of
requisite ORACLE
Oracle SQL supplies a rich library of in-built functions which can be employed for
various tasks. The essential capabilities of functions can be the case conversion of
strings, in-string or substring operations, mathematical computations on numeric data,
and date operations on date type values. SQL Functions optionally take arguments from
the user and mandatorily return a value.
Aggregate functions perform a variety of actions such as counting all the rows in a table,
Algorithm
averaging a column's data, and summing numeric data.
/Theory
Aggregates can also search a table to find the highest "MAX" or lowest "MIN" values in
a column. As with other types of queries, you can restrict, or filter out the rows these
functions act on with the WHERE clause. For example, if a manager needs to know how
many employees work in an organization, the aggregate function named COUNT(*) can
be used to produce this information. The COUNT(*) function shown in the below
SELECT statement counts all rows in a table.
FROM employees
MAX(expression)
MIN(expression)
Post Lab
Assignment
(If Any)
OUTPUT
NUMERIC
DATE FUNCTIONS
GROUP FUNCTIONS
SUM
AVG
MAX
MIN
COUNT
Experiment 6(a)
Title SET Operators.
Pre- Knowledge of
requisite Concept of SET Operators.
Syntax UNION
OUTPUT:
Experiment 6(b)
Title Joins
Pre- Knowledge of
requisite ORACLE COMMANDS
SQL JOIN
An SQL JOIN clause is used to combine rows from two or more tables, based on a
common field between them.
The most common type of join is: SQL INNER JOIN (simple join). An SQL INNER
JOIN return all rows from multiple tables where the join condition is me. SQL INNER
JOIN Keyword
The INNER JOIN keyword selects all rows from both tables as long as there is a match
between the columns in both table
The RIGHT JOIN keyword returns all rows from the right table (table2), with the
matching rows in the left table (table1). The result is NULL in the left side when there is
no match.
The FULL OUTER JOIN keyword returns all rows from the left table (table1) and from
the right table (table2).
The FULL OUTER JOIN keyword combines the result of both LEFT and RIGHT joins.
SQL INNER JOIN Syntax
SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name=table2.column_name;
SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;
Syntax
SQL RIGHT JOIN Syntax
SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name=table2.column_name;
SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2
ON table1.column_name=table2.column_name;
Post Lab
Assignment
(If Any)
OUTPUT:
INNER JOIN
LEFT JOIN
RIGHT JOIN
Pre- Knowledge of
requisite ORACAL COMMANDS
Subqueries:- A subquery is a form of an SQL statement that appears inside another SQL
statement. It also termed as nested query. The statement containing a subquery called a
parent statement. The rows returned but the subquery is use by the following statement.
5. To provide values for the condition in the WHERE, HAVING IN, SELECT,
UPDATE, and DELETE statements.
Exam:-
Union Clause:
The user can put together multiple queries and combine their output using the union
Syntax clause. The union clause merges the output of two or more queries into a single set of
rows and column. The final output of union clause will be
Output: = Records only in query one + records only in query two + A single set of records
with is common in the both queries.
Syntax:
FROM tablename 1
UNION
From tablename2;
Intersect Clause:
The use can put together multiple queries and their output using the interest clause. The
final output of the interest clause will be:
Syntax:
FROM tablename 1
INTERSECT
FROM tablename 2;
Minus Clause:-
The user can put together multiple queries and combine their output = records only in
query one
Syntax:
FROM tablename ;
MINUS
SELECT columnname, columnname
FROM tablename ;
Post Lab
Assignment
(If Any)
OUTPUT:
CREATING TABLE
UNION
INTERSECT
MINUS
Experiment 8
Title Control languages
Study and implement the concept of Data Control Language (DCL), Transaction Control
Objective
Language (TCL).
Pre- Knowledge of
requisite ORACAL COMMANDS
TCL command
Commit command
Algorithm Commit command is used to permanently save any transaction into database.
This command restores the database to last commited state. It is also use with savepoint
command to jump to a savepoint in a transaction.
Savepoint command
savepoint command is used to temporarily save a transaction so that you can rollback to
that point whenever necessary.
commit;
savepoint savepoint-name;
Post Lab
Assignment
(If Any)
OUTPUT:
SAVEPOINT
ROLLBACK
Experiment 9
Title Views
Pre- Knowledge of
requisite ORACLE COMMANDS
A view contains rows and columns, just like a real table. The fields in a view are fields
Algorithm from one or more real tables in the database.
/Theory You can add SQL functions, WHERE, and JOIN statements to a view and present the
data as if the data were coming from one single table.
Note: A view always shows up-to-date data! The database engine recreates the data,
using the view's SQL statement, every time a user queries a view.
SELECT newcolumnname….
FROM tablename
WHERE columnname=expression_list;
Selecting a data set from a view-
Syntax:-
FROM viewname
Destroying a view-
Syntax:-
Post Lab
Assignment
(If Any)
OUTPUT:
CREATE TABLE
CREATING VIEW
RENAMING VIEW
DROP VIEW