0% found this document useful (0 votes)
3 views58 pages

ADBMS SQL Command For Schedule Database (Autosaved)

The document outlines an advanced database lab focused on SQL, covering DDL, DML, DCL, and TCL statements. It includes an introduction to Oracle, methods for accessing the database, and detailed instructions for creating tables and managing users. The lab also emphasizes the use of aggregate functions, foreign key constraints, and transaction control commands in SQL.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views58 pages

ADBMS SQL Command For Schedule Database (Autosaved)

The document outlines an advanced database lab focused on SQL, covering DDL, DML, DCL, and TCL statements. It includes an introduction to Oracle, methods for accessing the database, and detailed instructions for creating tables and managing users. The lab also emphasizes the use of aggregate functions, foreign key constraints, and transaction control commands in SQL.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 58

Advanced Database lab

DDL,DML,DCL and TCL


statements in SQL.
Create database Schedule and
create four tables (student,
course, Instructor, room)
Outline
 First class
– Overview of the oracle database
– Ways of accessing oracle database
– Overview of sql developer
 2nd class
– Creating table using oracle sql developer(DML)
– Aggregate Function
– DCl
 3rd class
– Join operation and view
– TCl
– Trigger
 4th class
– Transaction isolation in sql
– Concurency trechniwues
– Oql
Introduction to Oracle

 Oracle is a product from Oracle Corporation that provides


a relational database management system. RDBMS
supports any kind of data model.
 It has different product editions, including Standard
Edition, Enterprise Edition, Express Edition, and Personal
Edition.
 The products are scalable and secure, with high-
performance ability, Backup and Recovery. .
Ways of accessing oracle database

1. Using Sql Plus


– To connect to Oracle Database from SQL*Plus:
– If you are on a Windows system, display a Windows
command prompt.
– At the command prompt, type sql/plus and press the
key Enter.
– SQL*Plus starts and prompts you for your user name.
– Type your user name and press the key Enter.
– SQL*Plus prompts you for your password.
– Type your password and press the key Enter.
2. web browser-based interface

 The Database home page is a web browser-based


interface for performing various database
administration operations, including the following:
– Monitoring database storage
– Monitoring database sessions
– Viewing database initialization parameters
– Getting started with Oracle Application Express
 To access the database home page, follow these
steps:
 Navigate the system menu as follows:
– On Windows, from the Start menu, select Programs (or All
Programs), then Oracle Database 11g Express Edition,
and then Get Started.
The Oracle Database XE home page
appears:

1.Click the button or tab for any category you are interested in (for
example, Storage).
If you are prompted for login information, specify:
•Username: Enter system for the user name.
•Password: Enter the password that was specified when Oracle
Database XE was installed.
1. To create the Application Express workspace:
1. From the system menu, navigate to Oracle Database 11g
Express Edition and select Get Started.
2. On the Database home page, click Application Express.
3. On the Login page, log in with the user name and password for
the SYSTEM account.
4. On the Oracle Application Express page, create a workspace for
the existing database user HR
3. Connecting to Oracle Database from SQL Developer

 SQL Developer is a client program with which you can access


Oracle Database. This section assumes that SQL Developer is
installed on your system, and shows how to start it and connect to
Oracle Database.
 SQL Developer is a graphical tool that enables you to browse,
create, edit, and delete (drop) database objects; run SQL statements
and scripts; edit and debug PL/SQL code; unload (export) and load
(import) data; migrate third-party databases to Oracle; and view
metadata and data.
 The instructions in this guide use SQL Developer for getting
started with database development.
Getting Started Using SQL Developer

 To start using SQL Developer to create and work with


objects and schemas in your XE database, follow these
major steps:
– Download and open setup and start SQL Developer
– Create some database connections,
– Connect to the database and work with database objects
 To create a new database connection:
1. In the Connections navigator, right-click the Connections
node and select New Database Connection. Look the
following
 In the connection definition in Figure 1:
– Connection Name: An alias for a connection to the database using the information that you enter.
Example: xe_chris
– Username: Name of the database user for the connection. This user must have
sufficient privileges to perform the tasks that you want to perform while
connected to the database. Example: chris
– Password: Password associated with the specified database user.
– Hostname: Host system for the Oracle database. For your Express Edition
database, the hostname is localhost.
– Port: Listener port. The default is 1521.
– SID: Database name. The default for Express Edition is xe.
 Click Test to check if you have entered the correct information for the connection.
 When the test is successful, click Save to save the connection.
 In the Oracle pane:
 For Role, accept the default.
 For Connection Type, accept the default (Basic).
 In the fields Hostname and Port, type the appropriate
values.
 Select the option SID.
 In the SID field, type the appropriate value.
 In the New/Select Database Connection window, click
the button Test.
 The connection is tested. If the connection succeeds, the
Status indicator changes from blank to. Success
Revision on Sql Command

 DDL
– CREATE − it creates a new table or new database, new user
– ALTER − it modifies an existing database object, such as a table.
– DROP − it deletes an entire table, other object in the DB.
– TRUNCATE TABLE: used to remove all rows from a table
without changed structure of table, it cannot be rollback.
 DML:
– SELECT − it retrieves certain records from tables.
– INSERT − it creates a record into table or view.
– UPDATE − it modifies the existing records.
– DELETE − it removes records from table or view.
DCL & TCL
 DCL means Data Control Language: These statements are used for
controlling the access to database objects for users.
 Generally these statements will be used by DBA people to control the
access of users to the database.
 DCL or Data Control Language commands in SQL
– GRANT − it gives or permits a privilege to user.
– REVOKE − it takes back or removes privileges granted from user.
 TCL: Transaction control language
– COMMIT: to save the data on the disk changes.
– ROLLBACK: to rolls back the changes.
– SAVEPOINT: creates points within groups of transactions in which to
ROLLBACK or COMMIT, it’s a mark or reference
– SET TRANSACTION: Places a name on a transaction.
lab1

 Create a connection
 create new user
 Dml
 sysntax
 create user username identified by password
 create user bobe identified by 12345
 grant connect, resourse to bobe
2nd class
DML, DCl and aggregate function

 Create table student


 Create table course
 Create table instructor
 Create table room
 Aggregate function
 Create table enrolment: relational table
 Create table course-offering: relational table
 Create table schedule
 Writing A query
Creating oracle user using sql
developer(DCL)

 Creating user using sql command


 Syntax: create user username identified by Password
– Create user MyUser identified by 12345; -- but check
weather user is exist?
 drop user MyUser
– create user MyUser identified by MyUser
 alter user mm identified by john
 DCL includes commands such as GRANT and REVOKE which mainly deal with
the rights, permissions, and other controls of the database system.
 List of DCL commands:
 GRANT: This command gives users access privileges to the database.
 Syntax:
– GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER,
ANOTHER_USER;
 REVOKE: This command withdraws the user’s access privileges
given by using the GRANT command.
– Syntax:
– REVOKE SELECT, UPDATE ON MY_TABLE FROM USER1, USER2;
DCL

 CREATE USER: The DBA creates user by executing CREATE USER


statement. The user is someone who connects to the database if enough
privilege is granted.
– Managing Users: - Create User, Delete User
– Managing Passwords
– Managing roles: - Grant , Revoke
 Objective: To understand the concept of administrative commands
 Syntax: SQL> CREATE USER < username> -- (name of user to be created )
IDENTIFIED BY <password> -- (specifies that the user’s password to login)
Eg: create user James identified by bob;
(The user does not have privilege at this time, it has to be granted. These
privileges determine what user can do at database level.)
 PRIVILEGES: A privilege is a right to execute an SQL statement or to
access another user's object.
 In Oracle, there are two types of privileges
– System Privileges
– Object Privileges
 System Privileges : are those through which the user can manage
the performance of database actions. It is normally granted by DBA to
users. Eg: Create Session,Create Table,Create user etc
 Object Privileges : allow access to objects or privileges on object,
i.e. tables, table columns. tables,views etc..It includes
alter,delete,insert,select update etc.
(After creating the user, DBA grant specific system privileges to user)
 GRANT: The DBA uses the GRANT statement to allocate system
privileges to other user.
– Syntax: SQL> GRANT privilege [privilege…. … ] TO USER ;
– Eg: Grant create session, create table, create view to James;
 Object privileges vary from object to object.An owner has all privilege or
specific privileges on object.
– SQL> GRANT object_priv [(column)] ON object TO user;
– SQL>GRANT select, insert ON employee TO James;
SQL>GRANT select ,update (e_name,e_address) ON employee TO James;
 CHANGE PASSWORD: The DBA creates an account and initializes a
password for every user.You can change password by using ALTER USER
statement.
– Syntax:Alter USER <some user name> IDENTIFIED BY<New password>
Eg: ALTER USER James IDENTIFIED BY sam
 REVOKE: REVOKE statement is used to remove privileges granted to
other users.The privileges you specify are revoked from the users.
– Syntax: REVOKE [privilege.. …] ON object FROM user
– Eg: REVOKE create session,create table from James;
– REVOKE select ,insert ON emp FROM James
 ROLE:
A role is a named group of related privileges that can be granted to
user.In other words, role is a predefined collection of previleges that
are grouped together,thus privileges are easier to assign user.
– SQL> Create role custom;
– SQL> Grant create table, create view TO custom;
– SQL> Grant select, insert ON emp TO custom;
– Eg: Grant custom to James, Steve;
 Syntax: GRANT SELECT, UPDATE ON MY_TABLE TO
SOME_USER, ANOTHER_USER;
 Example: GRANT CONNECT, SELECT, INSERT, UPDATE, DELET on student to
Alex
 REVOKE INSERT, SELECT on accounts from John
Example

 GRANT "CONNECT" TO MyUser ;


 GRANT CREATE ANY TABLE TO MyUser ;
 GRANT INSERT ANY TABLE TO " MyUser " ;
 REVOKE INSERT ANY TABLE From " MyUser " ;
 REVOKE CREATE any TABLE FROM " MyUser ";
Create Course and students tables
 create table course(cocode varchar(20) primary key,title varchar(30),crhr int)
 create table room(roomNO int, buldingNo varchar(10), floorno int)
 alter table room add constraint pk_roomNo primary key(roomNo)
 select sysdate from dual
 select * from schedule

 ALTER TABLE schedule ADD CONSTRAINT fk__schcode FOREIGN


KEY(cooffno) REFERENCES course_offering(cooffno);
 ALTER TABLE schedule ADD CONSTRAINT fk_schinsid FOREIGN
KEY(enroid) REFERENCES Stu_enrollement(enroid);

 ALTER TABLE schedule ADD CONSTRAINT fk_schroom FOREIGN


KEY(roomid) REFERENCES room(roomNo)
What is an Aggregate Function in SQL?

 An aggregate function in SQL returns one value after


calculating multiple values of a column. We often use aggregate
functions with the GROUP BY and HAVING clauses of the
SELECT statement. Association
 Various types of SQL aggregate functions are:
• Count(): select count(teacherID) from teacher
• select count(teacherID), depat from teacher group by dept
• Sum() select sum(sallery) from teacher
 Avg(): SELECT AVG (salary) FROM employees;
• Min()
• Max()
Difference Between DELETE and
TRUNCATE ::
 Delete is DML where as Truncate is DDL.
 Delete requires transaction control as it is DML. Truncate
does not require transaction control as it is DDL
 If we remove data using DML, then we can get back it by
giving Rollback (if commit not done). But
we cannot get the data removed by Truncate (auto
commit).
 Using Delete we can remove specific rows (using where
clause) or total rows also. But using Truncate
we can remove entire rows only. (we cannot use
where clause with truncate).
 Truncate is faster than Delete.
Course offering and erollement tables

 create table course_offering(cooffno varchar(20)primary


key,Ins_id varchar(20),cocode varchar(20))
 ALTER TABLE course_offering ADD CONSTRAINT
fk_insid FOREIGN KEY(Ins_id) REFERENCES
instractor(inid);
 ALTER TABLE course_offering ADD CONSTRAINT
fk_coc0de FOREIGN KEY(cocode) REFERENCES
course(cocode);
 create table Stu_enrollement(enroid varchar(20)primary
key,stid varchar(20),cocode varchar(20),year int,
semister int,section int)
Add foreign key constraints

 ALTER TABLE Stu_enrollement ADD CONSTRAINT


fk__enrollstid FOREIGN KEY(stid) REFERENCES
student(stid);
 ALTER TABLE Stu_enrollement ADD CONSTRAINT
fk_enrolcocode FOREIGN KEY(cocode) REFERENCES
course(cocode);
 create table schedule(schid varchar(20) primary
key,cooffno varchar(20), enroid varchar(20),roomid int,
dateTime date)
 insert into schedule values('sc01','off01', 'enr01',01, '16-02-
16');
Writing a query

 select
course.cocode,course.title,instractor.Ins_name,Stu_enroll
ement.year, Stu_enrollement.section,schedule.roomid,
schedule.dateTime
 from course,instractor, schedule,
Stu_enrollement,course_offering
 where stu_enrollement.cocode=course_offering.cocode
and schedule.cooffno=course_offering.cooffno
 alter table student add constraint primary
key(stidvarchar(20))
3rd class

 TCL
 Join
 Trigger
 view
TCL: Transaction control language

• In SQL, TCL stands for Transaction control language.


• A single unit of work in a database is formed after the
consecutive execution of commands is known as a transaction.
• There are certain commands present in SQL known as TCL
commands that help the user manage the transactions that take
place in a database.
• COMMIT. ROLLBACK and SAVEPOINT are the most
commonly used TCL commands in SQL.
Transaction control cont….

 Transaction Control: There are following commands used to control transactions:


– COMMIT: to save the changes.
– ROLLBACK: to rollback the changes.
– SAVEPOINT: creates points within groups of transactions in which to ROLLBACK
– SET TRANSACTION: Places a name on a transaction.
 Transaction control commands are only used with the DML commands INSERT,
UPDATE and DELETE only. They can not be used while creating tables or dropping
them because these operations are automatically committed in the database.
1. The COMMIT Command: The COMMIT command is the transactional command
used to save changes invoked by a transaction to the database. The COMMIT
command saves all transactions to the database since the last COMMIT or
ROLLBACK command. The syntax for COMMIT command is as follows:
COMMIT;
 The Following example which would delete records from
the table having department = IT and then COMMIT the
changes in the database.
SQL> DELETE FROM student WHERE dep = ‘IT’;
SQL> COMMIT;
 The result can show by using SELECT statement would
produce the following result:
2. The ROLLBACK Command:
 The ROLLBACK command is the transactional command used to undo
transactions that have not already been saved to the database. The
ROLLBACK command can only be used to undo transactions since the last
COMMIT or ROLLBACK command was issued. The syntax for ROLLBACK
command is as follows:
ROLLBACK;
 Consider the student table having the the records:
the example, which would delete records from the table having departement
= IT and then ROLLBACK the changes in the database.
 SQL> DELETE FROM student WHERE dep = ‘IT’;
SQL> ROLLBACK;
 As a result, delete operation would not impact the table and SELECT
statement would produce the result:
3. The SAVEPOINT Command:

 We can divide the database operations into parts. For example,


we can consider all the insert related queries that we will
execute consecutively as one part of the transaction and the
delete command as the other part of the transaction.
 Using the SAVEPOINT command in SQL, we can save these
different parts of the same transaction using different names.
 For example, we can save all the insert related queries with the
savepoint named INS. To save all the insert related queries in
one savepoint, we have to execute the SAVEPOINT query
followed by the savepoint name after finishing the insert
command execution.
Cont…

 A SAVEPOINT is a point in a transaction when you can roll the transaction


back to a certain point without rolling back the entire transaction.
 The syntax for SAVEPOINT command is as follows:
SAVEPOINT SAVEPOINT_NAME;
 This command serves only in the creation of a SAVEPOINT among
transactional statements.
 The ROLLBACK command is used to undo a group of transactions. The
syntax for rolling back to a SAVEPOINT is as follows:
ROLLBACK TO SAVEPOINT_NAME;
 Following is an example where you plan to delete the three different records
from the CUSTOMERS table. You want to create a SAVEPOINT before each
delete, so that you can ROLLBACK to any SAVEPOINT at any time to return
the appropriate data to its original state:
The RELEASE SAVEPOINT
Command:

 The RELEASE SAVEPOINT command is used to remove


a SAVEPOINT that you have created.
 The syntax for RELEASE SAVEPOINT is as follows:
RELEASE SAVEPOINT SAVEPOINT_NAME;
 Once a SAVEPOINT has been released, you can no
longer use the ROLLBACK command to undo
transactions performed since the SAVEPOINT.
TCL commands
 INSERT INTO student VALUES ('st05','melese',20,'male’);
 select * from student; -- on another login page or user use cmd command
 COMMIT; --- permanent save to hardisk----
 select * from course;
 UPDATE course SET crhr =4 where cocode='ccomp01';
 select * from course;
 ROLLBACK; ---undo the previous command
 select * from course;
 ----savepoint=================
 savepoint update1;
 UPDATE student SET age=22 WHERE stid='st02';
 savepoint update2;
 UPDATE student SET age=25 WHERE stid='st03';
 savepoint update3;
 UPDATE student SET age=30 WHERE stid='st04';

Trigger

 A block of code that is attached to an event. When


that event occurs the trigger code is fired.
 The trigger_name must be unique for triggers in the
schema. A trigger can have the same name as
another kind of object in the schema (for example, a
table);
 A stored block with [Declare], Begin, End.
 Associated with a database table or action
Oracle trigger usages

 Oracle triggers are useful in many cases such as the


following:
– Enforcing complex business rules that cannot be established
using integrity constraint such as UNIQUE, NOT NULL, and
CHECK.
– Preventing invalid transactions.
– Gathering statistical information on table accesses.
– Generating value automatically for derived columns.
– Auditing sensitive data.
syntax

CREATE [OR REPLACE] TRIGGER trigger_name timing event1 [OR


event2 OR event3] ON table_name
ENABLE ----------IT BEGIN THE ACTION EXECTION WHEN EXECUT THE EVENT
BEGIN
SQL statements;
END;
 Timing: refer before or after performing the event
 Event: refers DML commands (eg delete, update, insert,….)
 Action: it is a sequence of sql statements, but it could also be a database
transaction or external program that will be automatically executed.
1. 1CREATE OR REPLACE: The CREATE keyword specifies that you are creating a
new trigger. The OR REPLACE keywords are optional. They are used to modify an
existing trigger.
2. Trigger name: Specify the name of the trigger that you want to create after the
CREATE OR REPLACE keywords.
3. BEFORE | AFTER: The BEFORE or AFTER option specifies when the trigger
fires, either before or after a triggering event e.g., INSERT, UPDATE, or DELETE
4. ON table_name: The table_name is the name of the table associated with the
trigger.
5. FOR EACH ROW: The clause FOR EACH ROW specifies that the trigger is a row-
level trigger. A row-level trigger fires once for each row inserted, updated, or
deleted.
6. ENABLE / DISABLE: The ENABLE / DISABLE option specifies whether the
trigger is created in the enabled or disabled state. Note that if a trigger is disabled,
it is not fired when the triggering event occurs. By default, if you don’t specify the
clause ENABLE / DISABLE , the trigger is created with the enabled state.
 A trigger is a PL/SQL unit that is stored in the database and
(if it is in the enabled state) automatically executes ("fires") in
response to a specified event.
 A simple trigger can fire at exactly one of these timing points:
 Before the triggering event executes (statement-level
BEFORE trigger)
 After the triggering event executes (statement-level AFTER
trigger)
 Before each row that the event affects (row-level BEFORE
trigger)
 After each row that the event affects (row-level AFTER
trigger)
------------------------trigger to protect drop tables----------------
CREATE OR REPLACE TRIGGER RESTRIC_DROP_TABLE
BEFORE DROP ON DATABASE
SET SEREROUTPUT ON; ------To display the action message
ENABLE
BEGIN
Raise_application_error(-20001,'CAN NOT DROP TABLE
FROM THIS DATABASE');
END;
drop TABLE "student";
------------------------trigger to protect delete records----------------
CREATE OR REPLACE TRIGGER
RESTRIC_DELETE_recotds
BEFORE DELETE ON student

BEGIN
Raise_application_error(-20000,'CAN NOT DELETE
a record FROM THIS TABLE');
END;

DELETE from student;


------------------------trigger to count the number of records
----------------
CREATE OR REPLACE TRIGGER record_count_std
BEFORE INSERT OR DELETE OR UPDATE ON student
FOR EACH ROW
ENABLE
DECLARE NUM INTEGER;
BEGIN
SELECT COUNT(*) INTO NUM FROM STUDENT;
DBMS_OUTPUT.PUT_LINE(‘ there are now ’ || NUM || ’
students. ’ );
END;
DELETE from student where st_id=1;
Insert into student values(1, ‘mnb’, ‘comp’, 2);
------------------------trigger to control the user activity on each day---------------
CREATE OR REPLACE TRIGGER check_holiday_day_std
BEFORE INSERT ON student
FOR EACH ROW
ENABLE
BEGIN
IF to_char(sysdate, ‘dy’)=‘sun’ then
DBMS_OUTPUT.PUT_LINE(‘ holiday’ );
ELSE
DBMS_OUTPUT.PUT_LINE(‘ working day’ );
end if;
END;
Insert into student values(10, ‘mnb’, ‘comp’, 2);
 ---------------using trigger we can update integrity tables-----------
 --------------first create table and create
relation-----------------------------
 create table department
 ( deptno NUMBER(4) primary key,
 deptname varchar2(30),
 loc varchar2(30)
 );
 create table employee
 ( empno NUMBER(4) primary key,
 empname varchar2(30),
 depno NUMBER(4),foreign key (depno) references
department(deptno)
 );
---------------------insert some data for both tables------------------------------------
INSERT into department values(1,'com','ddu');
INSERT into employee values(1,'daud',1);
---------------using trigger we can update integrity tables-----------
UPDATE Department SET DEPTNO=2 WHERE DEPTNO=1; ---------------
error before creating trigger integrity constraint
CREATE OR REPLACE TRIGGER Department_trg
AFTER UPDATE OF DEPTNO ON Department
FOR EACH ROW
BEGIN
UPDATE EMPLOYEE SET DEPNO = :new.DEPTNO WHERE
DEPNO= :old.DEPTNO;
END;
UPDATE Department SET DEPTNO=2 WHERE DEPTNO=1;
SELECT * FROM department
-------------create login trigger--------------------------------
---first create table login_details their attribute is user name, date, action
Create table login_details(uname varchar(10),log_date date, action
varchar(10)
CREATE OR REPLACE TRIGGER login_trg
AFTER logon ON schema

BEGIN
insert into login_detaills values( USER, SYSDATE,'LOGIN’);
END;

DISC
CONN MISGIE
DISC
CONN MISGIE
select * from login_detaills;
Join
Join

 joins are used to retrieve data from 2 or more related tables


 in general tables are related to each other using foreign key
constraints
 There are diffrent types of joins
1. inner join: mathing rows only display, but not notmached rows
eg select empno,empname, deptname, from employee inner join department
on department.depno
1. outer join
2. cross join: produces the cartesian product of the 2 tables involved in the
join but has not any clause condition
 outer joins are again divided into
1. left join : returns all matched and non matched records from the left table
2. right join : returns all matched and non matched records from the right table
3. full join : returns all rows or records from both left and right table including
Join Example
---join========================================
----consider the above departement and employee
table========================
---inner join===============
select empno,empname, deptname from employee inner join Department on
employee.depno=department.deptno

---outer join===============
---1. left outer join=============
select * from employee left join Department on employee.depno=department.deptno
---2. right outer join=============
select * from employee right join Department on employee.depno=department.deptno
---3. full outer join=============
select * from employee full join Department on employee.depno=department.deptno

---3. cross join=============


select * from employee cross join Department
View

 View: it is a virtual table, which is the logical


representation of data from one or more table. It is not the
physical part of the database.
 View can be simple or complex view: simple is one table
and her is no function whereas complex can be more than
one table with function
 create view which display all employees details which
wrks the same department.
 CREATE VIEW emp_in_dep as Select * From “employee"
WHERE “deptno" = ‘1' ;
Example

---- view from single table


create view student_with_blk as select * FROM student WHERE blk_no=1;
SELECT * FROM student_with_blk;
select * from student;
insert INTO student values (5,'mulu','comp',1);
------ view can create from two different tables-----------------
------create view student with block--------------------
create view student_with_block as select student.ST_NAME, student.DEPT, BNO from student
inner join BLOCK on "BLK_NO" = Block.BNO;
select * from student_with_block;
------create view proctor with block--------------------
create view proctor_with_block_left as select P_NAME, "Manager_ID", BNO from proctor LEFT
join BLOCK on "Block_no" = Block.BNO;
select * from proctor_with_block_left;
------create view proctor with manager--------------------
create view proctor_with_manager_crossjoin as select P_NAME, "Block_no", M_NAME from
proctor CROSS join MANAGER;
select * from proctor_with_manager_crossjoin;
 THANK YOU !

You might also like