DBMS Lab MANUAL
DBMS Lab MANUAL
AIM:
To design and implement a database in Oracle using Structured Query Language commands
SYNTAX:
CREATE:
Create table <table name> (column name1 datatype1 constraints, column2 datatype2 . . .);
PROBLEM STATEMENT:
1) Branch
2) Account
3) Loan
4) Customer
Ex.No.2 PERFORMING INSERTION, DELETION, MODIFYING, ALTERING, UPDATING AND
VIEWING RECORDS BASED ON CONDITIONS.
AIM:
To implement and execute a query for manipulating & storing data items in a Oracle database using
Structured Query Language commands
DDL COMMANDS:
Create
Alter
Add
Modify
Drop
Rename
Drop
ALTER:
ADD:
Alter table <table name> add(column name1 datatype1);
MODIFY:
Alter table <table name> modify(column name1 datatype1);
DROP:
Alter table <table name> drop (column name);
RENAME:
Rename <old table name> to <new table name>;
DROP:
Drop table <table name>;
DML Commands:
Insert
Select
Update
Delete
INSERT:
Insert into <table name> values (‘attributes1’, ’attributes2’……);
SELECT:
Select <column name> from <table name>;
UPDATE:
Update <table name> set <column name>=’values’;
DELETE:
Delete from <table name>;
Ex.No.3 CREATION OF VIEWS, SYNONYMS, SEQUENCE, INDEXES, SAVE POINT.
AIM:
To implement and execute view, synonyms, sequence, indexes, savepoint in Oracle using Structured
Query Language commands
SYNTAX:
VIEWS:
SYNONYMS
SEQUENCE
INDEXES
SAVE POINT
AIM:
To Creating a Student database to set various constraints in Oracle using Structured Query Language
commands
VARIOUS CONSTRAINTS
Constraint
Constraint Meaning
Type
CHECK C Specifies a certain condition for a column, or group of columns.
NOT NULL C Not null column
PRIMARY KEY P primary key
FOREIGN KEY R foreign key
UNIQUE U unique
CHECK Specifies that DML operations on a view must satisfy the sub
V
OPTION query.
READ ONLY O Specifies that a view may only be read from.
AIM:
To Creating relationship between the databases in Oracle using Structured Query Language
commands
RULES FOR CREATING RELATIONSHIP BETWEEN THE DATABASES
TERNARY
BINARY N:M
AIM:
Declaration Section:
The Declaration section of a PL/SQL Block starts with the reserved keyword DECLARE. This
section is optional and is used to declare any placeholders like variables, constants, records and cursors,
which are used to manipulate data in the execution section. Placeholders may be any of Variables, Constants
and Records, which stores data temporarily. Cursors are also declared in this section.
Execution Section:
The Execution section of a PL/SQL Block starts with the reserved keyword BEGIN and ends with
END. This is a mandatory section and is the section where the program logic is written to perform any task.
The programmatic constructs like loops, conditional statement and SQL statements form the part of
executionsection.
Exception Section:
The Exception section of a PL/SQL Block starts with the reserved keyword EXCEPTION. This
section is optional. Any errors in the program can be handled in this section, so that the PL/SQL Blocks
terminates gracefully. If the PL/SQL Block contains exceptions that cannot be handled, the Block terminates
abruptly with errors. Every statement in the above three sections must end with a semicolon; PL/SQL
blocks can be nested within other PL/SQL blocks. Comments can be used to document code.
Ex.No.7 WRITE A PL/SQL BLOCK TO SATISFY SOME CONDITIONS BY ACCEPTING
INPUT FROM THE USER.
AIM:
Write a PL/SQL block to satisfy some conditions by accepting input from the user using oracle
SYNTAX
DECLARE
Variable declaration
BEGIN
Program Execution
EXCEPTION
Exception handling
END;
Ex.No.8 WRITE A PL/SQL BLOCK THAT HANDLES ALL TYPES OF EXCEPTIONS.
AIM:
To implement and execute PL/SQL Block that handles all types of exceptions in Oracle Database
using Procedural Language concepts.
EXCEPTIONS:
In PL/SQL, the user can catch certain runtime errors. Exceptions can be internally defined by Oracle
or the user. Exceptions are used to handle errors that occur in your PL/SQL code. A PL/SQL block contains
an EXCEPTION block to handle exception.
The predefined divide-by-zero exception has the following values for the attributes:
1. Name = ZERO_DIVIDE
2. Type = ORA (from the Oracle engine)
3. Exception Code = C01476
AIM:
To implement and execute Procedures in Oracle Database using Procedural Language concepts.
PROCEDURES:
1) Procedure is a sub program used to perform an action.
3 MODES:
1) IN – Means you must specify a value for the argument at the time execution of the procedure.
3) INOUT – When calling the procedure, yu must specify the value and that procedures passes value
back to the calling procedure.
SYNTAX:
Create or replace procedure <procedure_name> (argument {in, out, in out} data type) {is, as}
Variable declaration
Begin
Exception
End;
Ex.No.10 CREATION OF DATABASE TRIGGERS AND FUNCTIONS
AIM:
To implement and execute triggers and functions in Oracle Database using Procedural Language
concepts.
TRIGGERS:
1) Trigger is a special type of procedure that the oracle executes when an insert, modify or
delete operation is performed against a given table.
2) It is a stored sub program associated with a table.
3) It is used to keep an audit trial of a table, to prevent invalid transaction, enforce complex
security authorization, to generate data automatically.
SYNTAX:
FUNCTION:
1) A function is a sub program that accepts argument and returns a unique value to the caller.
FUNTION SYNTAX:
Create or replace function <function_name> (parameter{in, out, in out}) return <data type> is
Variable declaration
Begin
Pl/SQL Subprogram body.
Exception
Exception PL/SQL Block.
Return statement
End;
EX.NO.11 AIRLINE RESERVATION SYSTEM
AIM:
To implement and execute Airline Reservation System using cardinality function, relationship and
DDL query functions.
PROBLEM STATEMENT
IDENTIFICATION OF ENTITY:
PASSENGER
FLIGHT_INFORMATION
FLEET_INFORMATION
TICKET_DETAILS