Assignments DBMS 1-5
Assignments DBMS 1-5
ASSIGNMENT NO.1
AIM:
Study of Open Source Relational Databases : MySQL
OBJECTIVES:
Study of Open Source Relational Databases : MySQL
Theory:
MySQL is a Relational Management Database System(RDBMS), and ships with no GUI tools to
administer MySQL databases or manage data contained within the databases. Users may use the
included Command line tools, or use MySQL "front-ends", desktop software and web applications
that create and manage MySQL databases, build database structures, back up data, inspect status,
and work with data records. The official set of MySQL front-end tools, MySQL workbench is
actively developed by Oracle, and is freely available for use.
Client server system has one or more client process and one or more server processes,and a client
process can send a query to any one server [Link] are responsible for user-interface
issues,and servers manages data and execute transaction .Thus, aclient process could run on a
personal computer and send queries to a server to a server running on a mainframe
5] mySql> grant all privileges on *.* to root@<client_IP> identified by "mysql" with grant
option;
In this by following server client connectivity steps, we can eassily connect the client and
server.
Components of SQL:
1) DDL (Data Definition Language)
-This SQL syntax is used to create, modify and delete database [Link] syntax
cannot be applied to the manipulation of business [Link] is almost always used by the database
administrator, a database schema implementer or an application developer. Every DDL command
implicitly issues a COMMIT making permanent all changes in the database.
Examples:
CREATE: Create objects in database schema.
ALTER: Alters the structure of objects that exist within the database schema.
DROP: Drops objects that exist within database schema.
TRUNCATE: Removes all records from a table, including all space allocated for the
records.
COMMENT:Adds comments ,generally used for proper documentation of a database
schema.
2)DML(Data Manipulation Language)
-It is the SQL syntax that allows manipulating data within database tables.
Examples: INSERT, UPDATE, DELETE.
3)DCL(Data Control Language)
-It controls access to the database and table data. Occasionally DCL statements are
grouped with DML statements.
Examples:
COMMIT,SAVEPOINT,ROLLBACK,SET TRANSACTION
The commands used in MySQL are:
1) CREATE :
The CREATE command is used to create a database or create a table in a particular
database.
i) FOR CREATING A DATABASE :
Syntax:
create database database_name; //for creating a database
Example:
create database Student_info //Student_info database is created
ii)FOR CREATINGA TABLE:
The table creation command requires:
Name of the table
Names of fields
Definitions for each field
Syntax:
CREATE TABLE table_name (column_name1 column_type, column_name2 column_type,........);
Example:
create table Student(Roll_no tinyint PRIMARY KEY,Fname varchar(20) NOT NULL,Lname
varchar(20),Mob_no char(10));
2)ALTER:MySQLALTER command is used to change a name of your table, any table field or if
you want to add or delete an existing column in a table.
Syntax:
i)DROP- Used to delete a particular column.
Syntax: mysql> ALTER TABLE table_name DROP i; //i is the row you want to delete.
Syntax:
For example, to change column c from CHAR(1) to CHAR(10), do this:
mysql> ALTER TABLE table_name MODIFY c CHAR(10);
3)DELETE:used to delete a record from any MySQL table, then you can use SQL command
DELETE FROM.
Syntax:
DELETE FROM table_name [WHERE Clause]
INDEX:Indexing is the way of keeping table column data sorted so that searching and locating data
consumes less [Link] indexes essentially improve the speed at which records can be located
and retrieved from a table.
Types of Index:
SIMPLE INDEX: An index created on single column data is called Simple index.
COMPOSITE INDEX: An index created on multiple column data is called a composite index.
1)CREATE INDEX: A database index is a data structure that improves the speed of operations in
a table. Indexes can be created using one or more columns, providing the basis for both rapid
random lookups and efficient ordering of access to records.
Syntax:
CREATE UNIQUE INDEX index_name ON table_name ( column1, column2,...);
VIEWS: A view is a table whoes rows are not explicitly stored in the database but are computed as
needed from a view [Link] reduce redundant data to the minimum possible, MySQL allows
creation of an object called a view .A view is mapped to a SELECT statement. This technique
offers a simple, effective way of hiding columns of a table.
Example:
Conclusion:
ASSIGNMENT NO. 2
AIM:
Study of Design and Develop SQL DDL statements which demonstrate the use of SQL objects such
as Table, View, Index, Sequence, Synonym
OBJECTIVES:
Study of Design and Develop SQL DDL statements which demonstrate the use of SQL objects such
as Table, View, Index, Sequence, Synonym
Problem Statement:
(Create following tables with constraints, alter table, insert, drop table , rename table, view, index,
synonym, sequence/AUTO_INCREMENT)
Account(Acc_no, branch_name,balance)
branch(branch_name,branch_city,assets)
customer(cust_name,cust_street,cust_city)
Depositor(cust_name,acc_no)
Loan(loan_no,branch_name,amount)
Borrower(cust_name,loan_no)
Theory:
A schema is the collection of multiple database objects,which are known as schema [Link]
objects have direct access by their owner [Link] table lists the schema objects.
Table - to store data
View - to project data in a desired format from one or more tables
Sequence - to generate numeric values
Index - to improve performance of queries on the tables
Synonym - alternative name of an object
One of the first steps in creating a database is to create the tables that will store an organization's
[Link] design involves identifying system user requirements for various organizational
systems such as order entry, inventory management, and accounts receivable. Regardless of
database size and complexity, each database is comprised of tables.
Table of Contents
1. DDL
2. DML
3. DCL
4. TCL
DDL
DDL is short name of Data Definition Language, which deals with database schemas and
descriptions, of how the data should reside in the database.
CREATE - to create a database and its objects like (table, index, views, store procedure,
function, and triggers)
ALTER - alters the structure of the existing database
DROP - delete objects from the database
TRUNCATE - remove all records from a table, including all spaces allocated for the records
are removed
COMMENT - add comments to the data dictionary
RENAME - rename an object
DML
DML is short name of Data Manipulation Language which deals with data manipulation and
includes most common SQL statements such SELECT, INSERT, UPDATE, DELETE, etc., and it
is used to store, modify, retrieve, delete and update data in a database.
SELECT - retrieve data from a database
INSERT - insert data into a table
UPDATE - updates existing data within a table
DELETE - Delete all records from a database table
MERGE - UPSERT operation (insert or update)
CALL - call a PL/SQL or Java subprogram
EXPLAIN PLAN - interpretation of the data access path
LOCK TABLE - concurrency Control
DCL
DCL is short name of Data Control Language which includes commands such as GRANT and
mostly concerned with rights, permissions and other controls of the database system.
GRANT - allow users access privileges to the database
REVOKE - withdraw users access privileges given by using the GRANT command
TCL
TCL is short name of Transaction Control Language which deals with a transaction within a
database.
COMMIT - commits a Transaction
ROLLBACK - rollback a transaction in case of any error occurs
SAVEPOINT - to rollback the transaction making points within groups
SET TRANSACTION - specify characteristics of the transaction
-----------------------------------------------------------------------------------------------------------------------
SQL Statements For Tables
Constraints are the set of rules defined in Oracle tables to ensure data [Link] rules are
enforced placed for each column or set of [Link] the table participates in data action,
these rules are validated and raise exception upon violation. The available constraint types are NOT
NULL, Primary Key, Unique, Check, and Foreign Key.
The below syntax can be used to impose constraint at the column level.
Syntax:
column [data type] [CONSTRAINT constraint_name] constraint_type
All constraints except NOT NULL, can also be defined at the table level. Composite constraints can
only be specified at the table level.
A NOT NULL constraint means that a data row must have a value for the column specified as NOT
[Link] a column is specified as NOT NULL,the Oracle RDBMS will not allow rows to be stored
to the employee table that violate this [Link] can only be defined at column level, and not at
the table level.
Syntax:
COLUMN [data type] [NOT NULL]
UNIQUE constraint
Sometimes it is necessary to enforce uniqueness for a column value that is not a primary key
[Link] UNIQUE constraint can be used to enforce this rule and Oracle will reject any rows
that violate the unique [Link] constraint ensures that the column values are distinct,
without any duplicates.
Syntax:
Column Level:
COLUMN [data type] [CONSTRAINT <name>] [UNIQUE]
Table Level: CONSTRAINT [constraint name] UNIQUE (column name)
Note: Oracle internally creates unique index to prevent duplication in the column [Link]
would be discussed later in PL/SQL.
CREATE TABLE TEST
( ... ,
NAME VARCHAR2(20)
CONSTRAINT TEST_NAME_UK UNIQUE,
... );
In case of composite unique key,it must be defined at table level as below.
Each table must normally contain a column or set of columns that uniquely identifies rows of data
that are stored in the [Link] column or set of columns is referred to as the primary [Link]
tables have a single column as the primary [Link] key columns are restricted against NULLs
and duplicate values.
Points to be noted -
A table can have only one primary key.
Multiple columns can be clubbed under a composite primary key.
Oracle internally creates unique index to prevent duplication in the column [Link]
would be discussed later in PL/SQL.
Syntax:
Column level:
COLUMN [data type] [CONSTRAINT <constraint name> PRIMARY KEY]
Table level:
CONSTRAINT [constraint name] PRIMARY KEY [column (s)]
The following example shows how to use PRIMARY KEY constraint at column level.
CREATE TABLE TEST ( ID NUMBER CONSTRAINT TEST_PK PRIMARY KEY, ... );
The following example shows how to define composite primary key using PRIMARY KEY
constraint at the table level.
CREATE TABLE TEST ( ..., CONSTRAINT TEST_PK PRIMARY KEY (ID) );
Foreign Key
When two tables share the parent child relationship based on specific column, the joining
column in the child table is known as Foreign Key. This property of corresponding column in the
parent table is known as Referential integrity. Foreign Key column values in the child table can
either be null or must be the existing values of the parent table. Please note that only primary key
columns of the referenced table are eligible to enforce referential integrity.
If a foreign key is defined on the column in child table then Oracle does not allow the parent row to
be deleted,if it contains any child [Link],if ON DELETE CASCADE option is given at the
time of defining foreign key,Oracle deletes all child rows while parent row is being
[Link],ON DELETE SET NULL indicates that when a row in the parent table is deleted,
the foreign key values are set to null.
Syntax:
Column Level:
COLUMN [data type] [CONSTRAINT] [constraint name] [REFERENCES] [table name (column
name)]
Table level:
CONSTRAINT [constraint name] [FOREIGN KEY (foreign key column name) REFERENCES]
[referenced table name (referenced column name)]
The following example shows how to use FOREIGN KEY constraint at column level.
CREATE TABLE TEST (ccode varchar2(5) CONSTRAINT TEST_FK REFERENCES
PARENT_TEST(ccode), ... );
Check constraint
Sometimes the data values stored in a specific column must fall within some acceptable range of
values. A CHECK constraint requires that the specified check condition is either true or unknown
for each row stored in the table. Check constraint allows to impose a conditional rule on a column,
which must be validated before data is inserted into the column. The condition must not contain a
sub query or pseudo column CURRVAL NEXTVAL, LEVEL, ROWNUM, or SYSDATE.
Oracle allows a single column to have more than one CHECK constraint. In fact, there is no
practical limit to the number of CHECK constraints that can be defined for a column.
Syntax:
Column level:
COLUMN [data type] CONSTRAINT [name] [CHECK (condition)]
Table level:
CONSTRAINT [name] CHECK (condition)
The following example shows how to use CHECK constraint at column level.
CREATE TABLE TEST ( ..., GRADE char (1) CONSTRAINT TEST_CHK CHECK (upper
(GRADE) in ('A','B','C')), ... );
The following example shows how to use CHECK constraint at table level.
CREATE TABLE TEST ( ..., CONSTRAINT TEST_CHK CHECK (stdate < = enddate), );
create table Student_info(RollNO integer(10) NOT NULL, Name varchar(30), MobNo integer(10));
desc student_info;
show tables;
drop table student_info;
alter table student_info add(emailid varchar(30));
alter table student_info modify(emailid char(10));
rename Student_info to Stud_data;
create index idx on student_info(rollno);
alter table student_info drop index idx;
index::
show databases;
use student;
show tables;
desc student_info;
A table can be created from an existing table in the database using a subquery [Link] copies the
table structure as well as the data from the table. Data can also be copied based on [Link]
column data type definitions including the explicitly imposed NOT NULL constraints are copied
into the new table.
The below CTAS script creates a new table EMP_BACKUP. Employee data of department 20 gets
copied into the new table
.
CREATE TABLE EMP_BACKUP
AS
SELECT * FROM EMP_TEST
WHERE department_id=20;
Indexes are used to retrieve data from the database very fast. The users cannot see the indexes, they
are just used to speed up searches/queries.
Note: Updating a table with indexes takes more time than updating a table without
(because the indexes also need an update).
So, only create indexes on columns that will be frequently searched against.
CREATE INDEX Syntax
Example:
create index roll_no on student_info(rollno);
alter table student_info drop index roll_no;
Note: The syntax for creating indexes varies among different databases. Therefore: Check the
syntax for creating indexes in your database.
CREATE INDEX Example
The SQL statement below creates an index named "idx_lastname" on the "LastName" column in the
"Persons" table:
CREATE INDEX idx_lastname
ON Persons (LastName);
If you want to create an index on a combination of columns, you can list the column names within
the parentheses, separated by commas:
CREATE INDEX idx_pname
ON Persons (LastName, FirstName);
DROP INDEX Statement
MS Access:
DROP INDEX index_name ON table_name;
SQL Server:
DROP INDEX table_name.index_name;
DB2/Oracle:
DROP INDEX index_name;
MySQL:
ALTER TABLE table_name
DROP INDEX index_name;
SQL Sequence
Sequence is a feature supported by some database systems to produce unique values on demand.
Some DBMS like MySQL supports AUTO_INCREMENT in place of Sequence.
AUTO_INCREMENT is applied on columns, it automatically increments the column value by 1
each time a new record is entered into the table. Sequence is also some what similar to
AUTO_INCREMENT but it has some extra features.
Initial-value specifies the starting value of the Sequence, increment-value is the value by which
sequence will be incremented and maxvalue specifies the maximum value until which sequence will
increment itself. Cycle specifies that if the maximum value exceeds the set limit, sequence will
restart its cycle from the beginning. No cycle specifies that if sequence exceeds maxvalue an error
will be thrown.
Example to create Sequence
Once you use nextval the sequence will increment even if you don't Insert any record into the table.
CREATE SYNONYM:
Examples To define the synonym offices for the table locations in the schema hr, issue the
following statement:
To create a PUBLIC synonym for the employees table in the schema hr on the remote database, you
could issue the following statement:
Oracle Database Resolution of Synonyms: Example Oracle Database attempts to resolve references
to objects at the schema level before resolving them at the PUBLIC synonym level. For example,
the schemas oe and sh both contain tables named customers. In the next example, user SYSTEM
creates a PUBLIC synonym named customers for [Link]:
If the user sh then issues the following statement, then the database returns the count of rows from
[Link]:
To retrieve the count of rows from [Link], the user sh must preface customers with the
schema name. (The user sh must have select permission on [Link] as well.)
If the user hr's schema does not contain an object named customers, and if hr has select permission
on [Link], then hr can access the customers table in oe's schema by using the public synonym
customers:
A view contains rows and columns, just like a real table. The fields in a view are fields from one or
more real tables in the database.
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.
CREATE VIEW Syntax
CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
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.
SQL CREATE VIEW Examples
If you have the Northwind database you can see that it has several views installed by default.
The view "Current Product List" lists all active products (products that are not discontinued) from
the "Products" table. The view is created with the following SQL:
CREATE VIEW [Current Product List] AS
SELECT ProductID, ProductName
FROM Products
WHERE Discontinued = No;
Another view in the Northwind sample database selects every product in the "Products" table with a
unit price higher than the average unit price:
CREATE VIEW [Products Above Average Price] AS
SELECT ProductName, UnitPrice
FROM Products
WHERE UnitPrice > (SELECT AVG(UnitPrice) FROM Products);
Another view in the Northwind database calculates the total sale for each category in 1997. Note
that this view selects its data from another view called "Product Sales for 1997":
CREATE VIEW [Category Sales For 1997] AS
SELECT DISTINCT CategoryName, Sum(ProductSales) AS CategorySales
FROM [Product Sales for 1997]
GROUP BY CategoryName;
We can also add a condition to the query. Let's see the total sale only for the category "Beverages":
SELECT * FROM [Category Sales For 1997]
WHERE CategoryName = 'Beverages';
SQL Updating a View
You can update a view by using the following syntax:
SQL CREATE OR REPLACE VIEW Syntax
CREATE OR REPLACE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Now we want to add the "Category" column to the "Current Product List" view. We will update the
view with the following SQL:
CREATE OR REPLACE VIEW [Current Product List] AS
SELECT ProductID, ProductName, Category
FROM Products
WHERE Discontinued = No;
SQL Dropping a View
Examples:
insert into student_info values(3,'amol',2154455,'abc@gmai');
insert into student_info values(1,'vijay',21543255,'asvs@gmai');
select * from student_info;
view::
create view myview as select rollno,name from student_info;
select * from myview;
create view myview2 as select rollno,name from student_info where rollno>1;
(Create following tables with constraints, alter table, insert, drop table , rename table, view, index,
synonym, sequence/AUTO_INCREMENT)
Account(Acc_no, branch_name,balance)
branch(branch_name,branch_city,assets)
customer(cust_name,cust_street,cust_city)
Depositor(cust_name,acc_no)
Loan(loan_no,branch_name,amount)
Borrower(cust_name,loan_no)
[Link] Depositor table with foreign key with on delete cascade constraint on columns
cust_name and acc_no.
Q2. Create Borrower table with foreign key with on delete cascade constraint on columns
cust_name,loan_no.
Q3. Create Account table with primary key and AUTO_INCREMENT constraint on Acc_no
column
Q4. Create Loan table with primary key and AUTO_INCREMENT constraint on loan_no column.
Q5. Create Customer table with primary key constraint on cust_name column.
Q6. Create View on Account table and Loan Table.
Q7. Insert following Data into above tables
Q.8. Create synonym for customer table as cust.
Q.9. Create sequence acc_seq and use in Account table for acc_no column.
Q.10 Insert following data into all above tables.
**************************Problem Statements***********************
Q1. [Link] Depositor table with foreign key with on delete cascade constraint on columns
cust_name and acc_no.
Column Level:
SQL> create table depositor (cust_name varchar(20) CONSTRAINT FK_1 REFRENECS
customer(cust_name) ON DELETE CASCADE , acc_no integer(10) CONSTRAINT FK_2
REFRENECS account(acc_no) ON DELETE CASCADE);
Q2. Create Borrower table with foreign key with on delete cascade constraint on columns
cust_name,loan_no
Table level :
SQL> create table borrower (cust_name varchar(20), loan_no integer(10) , CONSTRAINT FK_1
FOREIGN KEY (cust_name) REFRENECS customer(cust_name) ON DELETE CASCADE,
CONSTRAINT FK_2 FOREIGN KEY (loan_no) FK2 REFRENECS loan(loan_no) ON DELETE
CASCADE);
Q3. Create Account table with primary key and AUTO_INCREMENT constraint on Acc_no
column
SQL> create table account (acc_no integer(10) primary key AUTO_INCREMENT, branch_name
varchar(20), balance integer(10));
Q4. Create Loan table with primary key and AUTO_INCREMENT constraint on loan_no column.
SQL> create table loan (loan_no integer(10) primary key AUTO_INCREMENT, branch_name
varchar(20), amount integer(10));
Q5. Create Customer table with primary key constraint on cust_name column.
SQL> create table customer (cust_name varchar(20) primary key, cust_street varchar(20), city
varchar(20));
Q.8. Create sequence acc_seq and use in Account table for acc_no column.
CREATE Sequence seq_1 start with 1 increment by 1 maxvalue 100000 no cycle ;
6 rows selected.
7 rows selected.
Create table Depositor(cust_name,acc_no):
CUST_NAME ACC_NO
-------------------- ----------
Rutuja 1005
Trupti 1002
Samiksha 1004
Loan(loan_no,branch_name,amount) :
SQL> select * from loan;
7 rows selected.
CUST_NAME LOAN_NO
-------------------- --------------
Mahima 2005
Trupti 2002
Rutuja 2004
Ayushi 2006
Priti 2007
Conclusion:
Thus we successfully implemented Table, View, Index, Sequence, Synonym MySQL queries.
Dr. D. Y. Patil Unitech Society's
ASSIGNMENT NO. 3
AIM:
To Design at least 10 SQL queries for suitable database application using SQL DML
statements: Insert, Select, Update, Delete with operators, functions, and set operator.
OBJECTIVES:
To Study and Design SQL queries for suitable database application using SQL DML statements:
Insert, Select, Update, Delete with operators, functions, and set operator.
Problem Statement:
(Insert, Select, Update, Delete, operators, functions, setoperator, all constraints, view, index,
synonym, sequence)
Account(Acc_no, branch_name,balance)
branch(branch_name,branch_city,assets)
customer(cust_name,cust_street,cust_city)
Depositor(cust_name,acc_no)
Loan(loan_no,branch_name,amount)
Borrower(cust_name,loan_no)
Input: insert Data into above tables and fire queries on databases;
Theory:
Set Operators:
The set operations union, intersect, and except operate on relations and correspond to the relational
algebra operations È, Ç, -.
Each of the above operations automatically eliminates duplicates; to retain all duplicates use the
corresponding multiset versions union all, intersect all and except all.
Aggregate Functions:
These functions operate on the multiset of values of a column of a relation, and return a value
avg: average value
min: minimum value
max: maximum value
sum: sum of values
count: number of values
Create above tables with appropriate constraints like primary key, foreign key, check constrains, not
null etc.
7 rows selected.
Create table Depositor(cust_name,acc_no):
CUST_NAME ACC_NO
-------------------- ----------
Rutuja 1005
Trupti 1002
Samiksha 1004
Loan(loan_no,branch_name,amount) :
7 rows selected.
CUST_NAME LOAN_NO
-------------------- --------------
Mahima 2005
Trupti 2002
Rutuja 2004
Ayushi 2006
Priti 2007
**************************Problem Statements***********************
BRANCH_NAME
--------------------
Akurdi
Nigdi
Akurdi
Wakad
Chinchwad
Akurdi
Akurdi
7 rows selected.
Q2. Find all loan numbers for loans made at Akurdi Branch with loan amount >12000.
LOAN_NO
----------
2006
2007
Q3. Find all customers who have a loan from bank. Find their names, loan_no and loan
amount.
Q4. List all customers in alphabetical order who have loan from Akurdi branch.
CUST_NAME
--------------------
Ayushi
Priti
Q5. Find all customers who have an account or loan or both at bank.
CUST_NAME
--------------------
Ayushi
MahimaPriti
Rutuja
Samiksha
Trupti
6 rows selected.
Q6. Find all customers who have both account and loan at bank.
SQL> select cust_name from depositer intersect select cust_name from borrower;
CUST_NAME
--------------------
Rutuja
Trupti
Q7. Find all customer who have account but no loan at the bank.
SQL> select cust_name from depositer minus select cust_name from borrower;
CUST_NAME
--------------------
Samiksha
AVG(BALANCE)
------------
14500
BRANCH_NAME AVG(BALANCE)
-------------------- ---------------------
Chinchwad 20000
Nigdi 14000
Wakad 10000
Akurdi 14500
10. Find no. of depositors at each branch.
BRANCH_NAME COUNT(BRANCH_NAME)
-------------------- -------------------------
Nigdi 1
Wakad 1
Akurdi 1
Q11. Find the branches where average account balance > 12000.
BRANCH_NAME
--------------------
Chinchwad
Nigdi
Wakad
Akurdi
NO_OF_TUPLES
------------
7
TOTAL_LOAN_AMOUNT
-----------------
33740
Q14. Delete all loans with loan amount between 1300 and 1500.
SQL> delete from loan where amount>1300 and amount<1500;
Q.17. Create sequence roll_seq and use in student table for roll_no column.
Conclusion:
ASSIGNMENT NO. 4
Problem Statement: Design SQL queries for suitable database application using SQL DML
statements: all types of Join, Sub-Query and View.
6. a) Create View on borrower table by selecting any two columns and perform insert update
delete operations
b) Create view on borrower and depositor table by selecting any one column from each table
perform insert update delete operations
c) create updateable view on borrower table by selecting any two columns and perform insert,
update and delete operations.
Solutions:
SQL> select add1,add2 from add_dets where code_no in(select custno from cust_mstr where
fname='Rutuja' and lname='Deshmane');
ADD1 ADD2
-------------------- --------------------
venu nagar dange chowk
List the customer holding fixed deposit of amount more than 5000
SQL> select fname,lname from cust_mstr where custno in(select codeno from acc_fd_cust_dets
where acc_fd_no in(select fd_sr_no from fd_dets where amt>5000));
FNAME LNAME
-------------------- --------------------
Rutuja Deshmane
Samiksha Dharmadhikari
3. Create following Tables
emp_mstr(e_mpno,f_name,l_name,m_name,dept,desg,branch_no)
branch_mstr(name,b_no)
List the employee details along with branch names to which they belong
List the employee details along with contact details using left outer join & right join
List the customer who do not have bank branches in their vicinity.
SQL> select * from cust_mstr where cust_no in (select code_no from add_dets where code_no like
'C%' and pincode not in (select pincode from add_dets where code_no like 'B%'));
6. A) Create View on borrower table by selecting any two columns and perform insert update delete
operations
SQL> select * from borrower;
NAME AMOUNT
---------- ---------------------
Aish 10000
Adi 10000
Swati 45216
B) Create view on borrower and depositor table by selecting any one column from each table
perform insert update delete operations
SQL> create view b3 as select amount loan, damount deposit from borrower, depositor;
View created.
LOAN DEPOSIT
---------- ----------
10000 45789
10000 7895
10000 79854
C) create updateable view on borrower table by selecting any two columns and perform insert,
Update and delete operations.
SQL> /
Enter value for acc: 102
Enter value for name: Adi
Enter value for amount: 4500
old 1: insert into borrower values(&acc,'&name',&amount)
new 1: insert into borrower values(102,'adi',4500)
1 row created.
SQL> /
Enter value for acc: 103
Enter value for name: Swati
Enter value for amount: 45216.
old 1: insert into borrower values(&acc,'&name',&amount)
new 1: insert into borrower values(103,'swati',45216.)
1 row created.
ACC_NO AMOUNT
---------- ----------
101 10000
102 4500
103 45216
104 45000
ACC_NO AMOUNT
---------- ----------
101 10000
102 4500
103 45216
Conclusion: