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

DBMS

1. The document contains SQL commands to create and populate tables for accounts, loans, installments and transactions. 2. It updates, alters, renames tables and selects data from the tables. 3. Temporary tables are also created from the main tables using the AS clause.

Uploaded by

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

DBMS

1. The document contains SQL commands to create and populate tables for accounts, loans, installments and transactions. 2. It updates, alters, renames tables and selects data from the tables. 3. Temporary tables are also created from the main tables using the AS clause.

Uploaded by

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

Practical - 02:

Table : ACCOUNT

1. create table ACCOUNT (acc_no varchar2(5), name varchar2(30), city varhar2(20),


balance number(10,2), loan_taken varchar2(5))

insert into ACCOUNT values('A001', 'Patel Jigar', 'Mehsana', 50000, 'YES')


insert into ACCOUNT values('A002', 'Patel Ramesh', 'Mehsana', 50000, 'YES')
insert into ACCOUNT values('A003', 'Dave Hardik', 'Ahmedabad', 75000, 'NO')
insert into ACCOUNT values('A004', 'Soni Hetal', 'Ahmedabad', 100000, 'NO')
insert into ACCOUNT values('A005', 'Sony Atul', 'Vadodara', 100000, 'YES')
2. update account set name = 'patel hiren' where name = 'Patel Jigar'
3. update account set name = 'kothari nehal', city = 'patan' where acc_no = 'A005'
4. select * from account where loan_taken = 'YES'
5. alter table account add (address varchar2(20))
6. create table account_temp (acc_no, name, balance) as select acc_no, name, balance from account
7. rename account to account_master
8. update account set balance = balance * 2
9. desc account
10. delete from account where acc_no = 'A004'

Table : LOAN

1. create table LOAN (loan_no varchar2(5), acc_no varchar2(5), loan_amt number(10,2),


interest_rate number(5,2), loan_date date, remaining_loan number(10,2))

insert into LOAN values('L001', 'A001', 100000, 7, '1-01-04', 75000)


insert into LOAN values('L002', 'A002', 300000, 9, '05-18-04', 150000)
insert into LOAN values('L003', 'A005', 500000, 11, '06-15-04', 300000)
2. update loan set loan_amt = loan_amt + 100000
3. update loan set interest_rate = interest_rate + 2
4. create table loan_temp (loan_no, Acc_no, loan_amt, loan_date) as select loan_no,
acc_no, loan_amt, loan_date from loan
5. select * from loan where loan_date between #01-01-04# and #01-31-04#
6. alter table loan add (credit_no varchar2(4))
7. select * from loan where
8. select * from loan order by date
9. select * from loan order by acc_no desc
10. alter table loan modify (acc_no varchar2(7))

Table : INSTALLMENT

1. create table INSTALLMENT (loan_no varchar2(5), inst_no varchar2(5), inst_Date date,


Amount number(10,2))

insert into INSTALLMENT values('L001', 'I001', '02-02-04', 15000)


insert into INSTALLMENT values('L002', 'I002', '05-18-04', 20000)
insert into INSTALLMENT values('L003', 'I003', '06-15-04', 20000)
2. update installment set inst_date = '03-3-04' where inst_date = '02-02-04'
3. update installment set Amount = Amount - 5000
4. update installment set Amount = Amount + 5000 where loan_no = 'L003' or loan_no = 'L002'
5. alter table installment modify (loan_no varchar2(7))
6. alter table installment modify (inst_no varchar2(4))
7. desc installment
8. update installment set Amount = 5000 where loan_no = 'L001'
9. delete from installment where loan_no = 'L002'
10. create table installment1 as (select * from installment where 1=2)

Table : TRANSACTION

1. create table TRANSACTION (acc_no varchar2(5), tr_Date date, Amt number(10,2),


type_of_tr char(1), mode_of_pay varchar2(10))

insert into TRANSACTION values('A001', '05-03-04', 10000, 'D', 'Cash')


insert into TRANSACTION values('A002', '07-05-04', 5000, 'W', 'Cheque')
insert into TRANSACTION values('A003', '08-12-04', 25000, 'D', 'Cheque')
insert into TRANSACTION values('A004', '05-15-04', 30000, 'D', 'Cheque')
insert into TRANSACTION values('A005', '10-22-04', 15000, 'W', 'Cash')
2. select distinct mode_of_pay from transaction
3. select * from transaction order by Acc_no desc
4. select Amt, tr_date, type_of_tr from transaction order by tr_date
5. create table transaction_temp (acc_no, tr_date, Amt, type_of_tr) as select acc_no,
tr_date, Amt, type_of_tr from transaction
6. create table trans_temp (account_no, tr_date, Amt, type_of_tr) as select acc_no,
tr_date, Amt, type_of_tr from transaction
7. drop table transaction_temp
8. rename transaction to trans
9. create table transaction1 as (select * from transaction where 1=2)
10. select acc_no from transaction where type_of_tr = 'D'

Name : Yog Raj Dhakal


Enroll : 91900103097

You might also like