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

Code DBMS

The document contains SQL queries to create and populate multiple tables in a database. It then performs various operations like inserting, updating, deleting and joining data across the tables and displays the results.

Uploaded by

nicad22625
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)
6 views

Code DBMS

The document contains SQL queries to create and populate multiple tables in a database. It then performs various operations like inserting, updating, deleting and joining data across the tables and displays the results.

Uploaded by

nicad22625
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/ 8

create Database DB3;

use DB3;

create table Book(sr integer, title varchar(100), Edition integer,Price integer, pubID varchar(100),
AID varchar(100) );

create table Authors( sr integer, AuthorID varchar(100), AName varchar(100), Aemail varchar(100) );

create table Publisher( sr integer, PID varchar(100), Pub_Name varchar(100), PCity varchar(100),
PEmail varchar(100));

create table Student(sr integer, PRNNO integer, SName varchar(100), RollNo integer,
Branch varchar(100), Year integer);

create table BorrowedBy1 (sr integer, TRXID varchar(100), IssueDate integer, RetDate integer,
Fine varchar(100), PRN integer, ISBN integer);

Q1. Add 5 records in each table and dieplay it


insert into Book values (1, "Ikigai", 2, 200, "P199", "A10");

insert into Book values (2, "how i can", 3, 299, "P289",

"A20");

insert into Book values (3, "May I", 4, 300, "A892", "S10");

insert into Book values (4, "Risk", 5, 400, "W218", "W10");

insert into Book values (5, "Life", 8, 500, "P5479", "P89");

select*from Book;
insert into Authors values (1, "A10", "Jack", "[email protected]");

insert into Authors values (2, "A20", "rock", "[email protected]");

insert into Authors values (3, "s10", "cat", "[email protected]");

insert into Authors values (4, "w10", "roman", "[email protected]");

insert into Authors values (5, "p89", "emma", "[email protected]");

select*from Authors;

insert into publisher values (1, "P29", "pratik",

"Mumbai","[email protected]");

insert into publisher values (2, "P24", "umesh", "pune", "[email protected]");

insert into publisher values (3, "P19", "prathmesh", "Delhi", "[email protected]");

insert into publisher values (4, "P22", "shruti", "banglore", "[email protected]");

insert into publisher values (5, "P49", "vishal", "kolkata",

"[email protected]");

select*from publisher;
insert into Student values (1, 1234, "Aniket", 12, "entc", 1);

insert into Student values (2, 1224, "nakul", 14, "cse", 2);

insert into Student values (3, 1134, "Om", 22, "it", 3);

insert into Student values (4, 1276, "Ram", 32, "mach", 4);

insert into Student values (5, 1864, "Hariom", 52, "civil",5);

select*from student;

insert into BorrowedBy1 values (1,"t21",'2022/01/01','2022/08/08',"no fine", 76543,89632 );

insert into BorrowedBy1 values (2,"t22",'2022/01/01','2022/09/09',"RS-10", 76533,89532 );

insert into BorrowedBy1 values (3,"t23",'2022/01/01','2022/09/09',"RS-10", 74533,84532 );

insert into BorrowedBy1 values (4,"t24",'2022/02/01','2022/03/07',"RS-10", 76773,85532 );

insert into BorrowedBy1 values (2,"t22",'2022/03/03','2022/09/09',"NO FINE", 76533,89532 );

select*from BorrowedBy1 ;
Q2. Remove all records where Publisher Name is umesh

delete FROM PUBLISHER WHERE Pub_Name=’umesh’;

select*from publisher;

Q3.Change Book title where ISBNNO is 2

update book set

ISBN=2 WHERE

AID="A10" ;

select*from book;

Q4. Change Author’s email id for where Author name is cat

update authors

set aemail="[email protected]"

where AName=’cat’;

select*from authors;
Q5. Change book Price to 399 for “how I can” book

update book set

PRICE=399 WHERE

title=’how I can’

select*from book;

Q6. Display books whose price range between 300 and 500

select * from book where price between 300 and 500;


Q7. Delete all records of author is jack
delete from authors where AName='jack';
select * from authors;

Q8.Display cartesian product for authors and book

select authors.AName, book.title from authors cross join book ;

Q9.Display natural join of book and authors

select authors.AName, book.title from authors natural join book;


Q10.Display inner join of book and authors

select authors.AName, book.title


from authors
inner join book on
authors.AuthorID=book.AID;

Q11. Display books published by a publisher name shruti

select * from publisher where Pub_Name='shruti';

You might also like