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

Library Dbms

The document contains SQL commands for creating tables to manage a library database, including tables for the library collection, students, and book check-outs. It also includes procedures for adding data to these tables, such as adding new books, students, and check-out/return transactions. Sample insert and call statements are provided to demonstrate how the procedures can be used to populate and interact with the database tables.

Uploaded by

RAJ ABHISHEKH
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Library Dbms

The document contains SQL commands for creating tables to manage a library database, including tables for the library collection, students, and book check-outs. It also includes procedures for adding data to these tables, such as adding new books, students, and check-out/return transactions. Sample insert and call statements are provided to demonstrate how the procedures can be used to populate and interact with the database tables.

Uploaded by

RAJ ABHISHEKH
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

/u/0/#inbox/FMfcgzGqQmNcmrrWCFdWcCJsmvKhSfh?projector=1&messagePartld=0.

#Command for creating table for library:


CREATE TABLE library

book ID number,

book NAME varchar(20),


book author varchar(20)

#Command for insertion of values


INSERTAl
INTO library VALUES(1001, diary of a wilnpy kidjeronimo stilton
INTOlibrary VALUES(1002,harry potterharry bhai')
INTOlibrary VALUES(1003,eracle is back, dr gajendra
INTOlibrary VALUES(1004,dsa made easynaresh kumar
INTOlibrary VALUES(1005, numerical methods dr bs grewal
INTOlibrary VALUES(1006, computer architecture morris mano
INTO library VALUES(1007, java with us victor
INTO library VALUES(1008,kool kotlin dr.rk
INTO library VALUES(1009, let us c++ yashwant kanetkar')
INTO Ilibrary VALUES(1010,DR.dbms dr.prateek)
SELECT FROM dual;
GLI

INTO library VALUES(1004,dsa made easy, naresh kumar)

INTO library VALUES(1005,numerical methods,dr bs grewal')


INTOlibrary VALUES(1006,computer architecture", morris mano')
INTO library VALUES(1007, java with us', victor)
INTOlibrary VALUES(1008,kool kotlin 'dr.rk)
INTOlibrary VALUES(1009,let usc++yashwantkanetkar)
INTOlibrary VALUES(1010,DR.dbmsdr.prateek
SELECTFROM dual;

OUTPUT

B0OK 1D EBOOKNAME EOOKAUTHOR


1001 diary of ayrinpy id jeroninso stilto
1002 harry hhai

1003 oracie i back dir gajendra

1004 naresh kuma


dsa made eas
1905 Fiurarical mettrods dr be gewal
1006 computefatchite cture EE mano
1008 kool kotin dr.rk
1009 let us c yashwant kanetkar

1010 dr prateek

#Commandfor creating table for student:


CREATE TABLE STUDENT
ROLLNO NUMBER
NAMEARCHAR(20
GENDER VARCHAR(1,
BRANCH VARCHAR{20),
CONSTRAINT PK PRIMARY KEYROLL NO

Creating procedure for adding student:


CREATE OR REPLACE PROCEDURE ADD_STUDENT (NAME VARCHAR,GEN
VARCHAR,BRHVARCHAR,ROLLNUMBER
AS

BEGIN
INSERT INTO STUDENT VALUES (ROLLNAME,GEN,BRH);
END
BEGIN
ADD_STUDENT( AMIT M I T s
Page 1 Q
END
#Creating procedure for adding student:

CREATE OR REPLACE PROCEDURE ADD STUDENT (NAME VARCHAR,GEN


VARCHAR,BRH VARCHAR.ROLL NUMBER)
AS
BEGIN
INSERTINTO STUDENT VALUES (ROLLNAME GEN,BRH);
END;
BEGIN

ADD_STUDENT(AMIT MT 95)
END

OUTPUT
#inbox/FMfcgzGqQmNcmrr/WCFdWcCJsmvKhSfh?projector=1&messagePartld=0.1

AMIT

#Command for creating table for issuing book:


CREATE TABLE issue

(roll_no number,
book ID number,
issue_date date

#Command for insertion of values


INSERT ALL

INTOissue VALUES(1,1003 21-SEP 22)


INTO issue VALUES(3,1002,'13-JAN-21]
SELECT FROM DUAL;

#Creating procedure for borrowing book


CREATE OR REPLACE PROCEDURE borrowfroll no number, book id number)
AS

BEGIN

INSERT INTO issue

VALUES(roll_no,book ld, sysdate)


END
Proeedr
#Creating procedure for borrowing book
CREATE OR REPLACE PROCEDURE borrow(roll no number, book id number)
AS
BEGIN
INSERTINTO issue
VALUES roll_ no,book id, sysdate)
END
Procedure created.

#Creating procedure for returning book:

CREATE OR REPLACE PROCEDURE return


book(rollnumber number, bookid
number)
AS
BEGIN
DELETE FROt
CREATE OR REPLACE PROCEDURE
number
return book(rollnumber number, bookid
AS
BEGIN

DELETEFROM issue
WHERE roll no=rollnumber AND book
id-bookid;
END
Proced reated

BEGIN
borrow 3,1001
END
Statement processed

BEGIN
return book(3,1001);
END;
Statement pr

#Creating propug IeOH borreaing book


LIa-u.T
return book(3,1001)
END;
Statement processed

#Creating procedure for borrowing book:


CREATE OR REPLACE PROCEDURE add book(bookid
number, bookname
varchar, author varchar
AS
BEGIN
INSERT INTO library
VALUES(bookid, bookname, author)
END
Procedure created

#Creating procedure for deleting book


CREATE OR REPLACE mber, bookname
varchar, author varcharPae
/#inbox/FMfcgzGqQmNcmrrWCFdWcCJsmvkhSfh?projector 1&messagePartld=0.1

#Creating procedure for deleting book:


CREATE OR REPLACE PROCEDURE delete book{bookid number,bookname
varchar, author varchar
AS
BEGIN

DELETE FROM library

WHERE book id= bookid;


END
Procedure createdr

You might also like