Practical 1 Implementation of Partition_Hash, Range, List
Practical 1 Implementation of Partition_Hash, Range, List
1 (A) - Create book table ( book_id (pk), title, author, price, book_rating )
with range
partition on rating with rating 1, 2 and 3 for three different partitions. Insert
at least 10
records in the table.
INSERT INTO books (book_id, title, author, price, book_rating) VALUES (1, 'Romeo
and Juliet', 'William Shakespeare', 1200.00,3);
INSERT INTO books (book_id, title, author, price, book_rating) VALUES (2, 'The
world as I see it', 'Albert Einstein', 200.00,2);
INSERT INTO books (book_id, title, author, price, book_rating) VALUES (3,
'Principia', 'Isaac Newton', 240.50,3);
INSERT INTO books (book_id, title, author, price, book_rating) VALUES (4, 'A Bunch
of Old Letter', 'Jawaharlal Nehru', 175.50,2);
INSERT INTO books (book_id, title, author, price, book_rating) VALUES (5,
'Anandmath', 'Bankim Chandra Chatterjee', 1290.00,1);
INSERT INTO books (book_id, title, author, price, book_rating) VALUES (6, 'An
Autobiography', 'Jawaharlal Nehru', 190.00,3);
INSERT INTO books (book_id, title, author, price, book_rating) VALUES (7, 'Broken
Wings', 'Sarojini Naidu', 350.50,2);
INSERT INTO books (book_id, title, author, price, book_rating) VALUES (8, 'Bubble',
'Mulk Raj Anand', 150.00,1);
INSERT INTO books (book_id, title, author, price, book_rating) VALUES (9, 'By God's
Decree', 'Kapil Dev', 160.50,2);
INSERT INTO books (book_id, title, author, price, book_rating) VALUES (10, 'Court
Dancer', 'Rabindranath Tagore', 1240.50,3);
Q.1 (B) Display all the books with the rating 2 and price in the range 200 and
1000.
SELECT * FROM books WHERE book_rating = 2 AND price BETWEEN 200 AND 1000;
Q.2 (A) - Create 3 partition in table cabinet using Range partition on cid Column
of cabinet
(cid, mem_name, address, state_rep, phone_number, sal) P1 cid <101 ; P2
cid<501 ; P3 cid
<1001. Insert at least 10 records in the table.
INSERT INTO cabinet (cid, mem_name, address, state_rep, phone_number, sal) VALUES
(20, 'Omkar Gawas', 'Mirzole', 'Rep A', '123-456-78', 50000.00);
INSERT INTO cabinet (cid, mem_name, address, state_rep, phone_number, sal) VALUES
(50, 'Patu Harmalkar', 'Redi vengurla', 'Rep B', '987-654-3210', 40000.00);
INSERT INTO cabinet (cid, mem_name, address, state_rep, phone_number, sal) VALUES
(75, 'Akshay Sawant', 'Sawantwadi', 'Rep C', '456-789-0123', 55000.00);
INSERT INTO cabinet (cid, mem_name, address, state_rep, phone_number, sal) VALUES
(150, 'Deep Aravandekar', 'Aronda vengurla', 'Rep D', '321-654-9878', 70000.00);
INSERT INTO cabinet (cid, mem_name, address, state_rep, phone_number, sal) VALUES
(200, 'Tushar Desai', 'Dodamarg', 'Rep E', '654-321-0987', 65000.00);
INSERT INTO cabinet (cid, mem_name, address, state_rep, phone_number, sal) VALUES
(300, 'Dipak Gawade', 'Camp Vengurla', 'Rep F', '789-012-3456', 72000.00);
INSERT INTO cabinet (cid, mem_name, address, state_rep, phone_number, sal) VALUES
(400, 'Mayur Gawade', 'Amboli Sawantwadi', 'Rep G', '123-789-4560', 68000.00);
INSERT INTO cabinet (cid, mem_name, address, state_rep, phone_number, sal) VALUES
(550, 'Pajwal Muthye', 'Pernem Goa', 'Rep H', '789-654-1230', 75000.00);
INSERT INTO cabinet (cid, mem_name, address, state_rep, phone_number, sal) VALUES
(700, 'Aditya Gawandi', 'Redi Vengurla', 'Rep I', '345-678-9012', 80000.00);
INSERT INTO cabinet (cid, mem_name, address, state_rep, phone_number, sal) VALUES
(900, 'Siddesh Gulekar', 'Sawantwadi', 'Rep J', '678-901-2345', 78000.00);
Q 3 (A)-Create table Employee with attributes empid, name, age, salary and joining
date by
using hash partition based on employee salary with minimum3 partitions. Insert at
least 10
records in the table.
Q 3 (B) -Display the information about the employee in the third partition.
Q 5 (A)-Create table Bank with fields Bankld, BName, Location. Partition the Bank
table
based on Location as per following.
BK1 = (Mumbai, Pune, Nashik), BK2 = (Lucknow, Kanpur, Varanasi)
BK3 = (Chandigarh, Mohali, Amritsar), BK4 = (GandhiNagar, Ahmedabad, Surat)
Insert 10 records in Bank table.
INSERT INTO Bank (BankId, BName, Location) VALUES (1, 'Punjab National Bank',
'Varanasi');
INSERT INTO Bank (BankId, BName, Location) VALUES (2, 'Yes Bank', 'Chandigarh');
INSERT INTO Bank (BankId, BName, Location) VALUES (3, 'Kotak Mahindra Bank',
'Mohali');
INSERT INTO Bank (BankId, BName, Location) VALUES (4, 'IndusInd Bank',
'Ahmedabad');
INSERT INTO Bank (BankId, BName, Location) VALUES (5, 'Union Bank', 'Surat');
INSERT INTO Bank (BankId, BName, Location) VALUES (6, 'HDFC Bank', 'Mumbai');
INSERT INTO Bank (BankId, BName, Location) VALUES (7, 'ICICI Bank', 'Pune');
INSERT INTO Bank (BankId, BName, Location) VALUES (8, 'Axis Bank', 'Nashik');
INSERT INTO Bank (BankId, BName, Location) VALUES (9, 'State Bank of India',
'Lucknow');
INSERT INTO Bank (BankId, BName, Location) VALUES (10, 'Bank of Baroda', 'Kanpur');