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

Exercises: Q1. Consider The Following Schema

The document contains questions related to SQL table operations. Q1 asks to create an orders table from data, add columns, and copy rows. Q2 asks to create an employee table,

Uploaded by

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

Exercises: Q1. Consider The Following Schema

The document contains questions related to SQL table operations. Q1 asks to create an orders table from data, add columns, and copy rows. Q2 asks to create an employee table,

Uploaded by

himani tewatia
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Exercises

Q1. Consider the following schema


ord_no purch_amt ord_date customer_id salesman_id

70001 150.5 2012-10-05 3005 5002

70009 270.65 2012-09-10 3001 5005

70002 65.26 2012-10-05 3002 5001

70004 110.5 2012-08-17 3009 5003

70007 948.5 2012-09-10 3005 5002

70005 2400.6 2012-07-27 3007 5001

70008 5760 2012-09-10 3002 5001

70010 1983.43 2012-10-10 3004 5006

70003 2480.4 2012-10-10 3009 5003

70012 250.45 2012-06-27 3008 5002

70011 75.29 2012-08-17 3003 5007

70013 3045.6 2012-04-25 3002 5001

1. Create the table orders with columns order_no number type, purch_amt
number(precision, scale), ord_date date, customer_id number and salesman_id
number
2. Insert the values as given in the table
3. Add customer name, email address and contact_number columns in the given
table
4. Add column gender in the table with single character value.
5. Update the values of newly added columns in the records
6. Create another table orders_completed with ord_no, purch_amt, ord_date and
customer name, email_address and contact number. Then copy the information
of details from orders table where date is 10th October 2012.
Q2. Consider the following schema
I FNAME LNAME GENDER SALARY HIREDATE

1 Rajveer Singh M 30000 2017/11/05

2 Manveer Singh M 50000 2017/11/05

3 Ashutosh Kumar M 40000 2017/12/12

4 Ankita Sharma F 45000 2017/12/15

5 Vijay Kumar M 50000 2018/01/12

6 Dilip Yadav M 25000 2018/02/26

7 Jayvijay Singh M 30000 2018/02/18

8 Reenu Kumari F 40000 2017/09/19

9 Ankit Verma M 25000 2018/04/04

10 Harpreet Singh M 50000 2017/10/10

1. Create table Employee.


2. Insert the values as mentioned.
3. Add column Employee ID as identity column.
4. Modify the column salary to store floating point values.
5. Rename the attribute FNAME to Emp_name.
6. Drop column LNAME from the employee table.
7. Add column Department with default value as ‘CSE’
8. Add an annual increment to the salary of employee whose joining date is 19th
September 2017.
9. Modify the department value of DILIP and VIJAY to ME
10. Delete the employees belonging to ME department

Q3. Consider the table in question 2

1. Apply Truncate command


2. Apply Drop command

3. Apply Delete command to delete all records at once.

Analyze the difference.

Q4. Consider the following schema

|CUST_CODE | CUST_NAME | CUST_CITY | WORKING_AREA |


CUST_COUNTRY | GRADE | OPENING_AMT | RECEIVE_AMT | PAYMENT_AMT |
OUTSTANDING_AMT| PHONE_NO | AGENT_CODE |

+-----------+-------------+-------------+--------------+--------------+-------+-------------
+-------------+-------------+---------------+--------------+------------+

| C00013 | Holmes | London | London | UK | 2| 6000.00 | 5000.00 |


7000.00 | 4000.00 | BBBBBBB | A003 |

| C00001 | Micheal | New York | New York | USA | 2| 3000.00 |


5000.00 | 2000.00 | 6000.00 | CCCCCCC | A008 |

| C00020 | Albert | New York | New York | USA | 3| 5000.00 |


7000.00 | 6000.00 | 6000.00 | BBBBSBB | A008 |

| C00025 | Ravindran | Bangalore | Bangalore | India | 2| 5000.00 |


7000.00 | 4000.00 | 8000.00 | AVAVAVA | A011 |

| C00024 | Cook | London | London | UK | 2| 4000.00 | 9000.00 |


7000.00 | 6000.00 | FSDDSDF | A006 |

| C00015 | Stuart | London | London | UK | 1| 6000.00 | 8000.00 |


3000.00 | 11000.00 | GFSGERS | A003 |

| C00002 | Bolt | New York | New York | USA | 3| 5000.00 |


7000.00 | 9000.00 | 3000.00 | DDNRDRH | A008 |

| C00018 | Fleming | Brisban | Brisban | Australia | 2| 7000.00 | 7000.00 |


9000.00 | 5000.00 | NHBGVFC | A005 |

| C00021 | Jacks | Brisban | Brisban | Australia | 1| 7000.00 | 7000.00 |


7000.00 | 7000.00 | WERTGDF | A005 |

| C00019 | Yearannaidu | Chennai | Chennai | India | 1| 8000.00 | 7000.00


| 7000.00 | 8000.00 | ZZZZBFV | A010 |

| C00005 | Sasikant | Mumbai | Mumbai | India | 1| 7000.00 | 11000.00


| 70f00.00 | 11000.00 | 147-25896312 | A002 |
| C00007 | Ramanathan | Chennai | Chennai | India | 1| 7000.00 |
11000.00 | 9000.00 | 9000.00 | GHRDWSD | A010 |

| C00022 | Avinash | Mumbai | Mumbai | India | 2| 7000.00 |


11000.00 | 9000.00 | 9000.00 | 113-12345678 | A002 |

| C00004 | Winston | Brisban | Brisban | Australia | 1| 5000.00 | 8000.00 |


7000.00 | 6000.00 | AAAAAAA | A005 |

| C00023 | Karl | London | London | UK | 0| 4000.00 | 6000.00 |


7000.00 | 3000.00 | AAAABAA | A006 |

| C00006 | Shilton | Torento | Torento | Canada | 1| 10000.00 | 7000.00 |


6000.00 | 11000.00 | DDDDDDD | A004 |

| C00010 | Charles | Hampshair | Hampshair | UK | 3| 6000.00 |


4000.00 | 5000.00 | 5000.00 | MMMMMMM | A009 |

| C00017 | Srinivas | Bangalore | Bangalore | India | 2| 8000.00 | 4000.00 |


3000.00 | 9000.00 | AAAAAAB | A007 |

| C00012 | Steven | San Jose | San Jose | USA | 1| 5000.00 | 7000.00 |


9000.00 | 3000.00 | KRFYGJK | A012 |

| C00008 | Karolina | Torento | Torento | Canada | 1| 7000.00 | 7000.00 |


9000.00 | 5000.00 | HJKORED | A004 |

| C00003 | Martin | Torento | Torento | Canada | 2| 8000.00 | 7000.00 |


7000.00 | 8000.00 | MJYURFD | A004 |

| C00009 | Ramesh | Mumbai | Mumbai | India | 3| 8000.00 | 7000.00


| 3000.00 | 12000.00 | Phone No | A002 |

| C00014 | Rangarappa | Bangalore | Bangalore | India | 2| 8000.00 |


11000.00 | 7000.00 | 12000.00 | AAAATGF | A001 |

| C00016 | Venkatpati | Bangalore | Bangalore | India | 2| 8000.00 |


11000.00 | 7000.00 | 12000.00 | JRTVFDD | A007 |

| C00011 | Sundariya | Chennai | Chennai | India | 3| 7000.00 | 11000.00


| 7000.00 | 11000.00 | PPHGRTS | A010 |

+-----------+-------------+-------------+--------------+--------------+-------+-------------
+-------------+-------------+---------------+--------------+------------+

Create the table Customer_details with following columns

CUST_CODE
CUST_NAME
CUST_CITY
WORKING_AREA
CUST_COUNTRY
GRADE
OPENING_AMT
RECEIVE_AMT
PAYMENT_AMT
OUTSTANDING_AMT
PHONE_NO
AGENT_CODE

Insert the values as shown in the table

Perform following operations on the above table


1. Modify phone number column to number data type.
2. Update the values of all records corresponding to newly added columns.
3. Add Gender column in single char value.
4. Add order_time column of timestamp type.
5. Update the outstanding amount to 0 for all customers from India.
6. View all the Britishers whose outstanding amount is greater than 7000.
7. Add column feedback with clob data type.
8. Remove all customers with grade 2.

Q5. Create table EMP with the following description :


Name Type
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(3)
AGE NUMBER(3)

1. Insert 5 records as shown in table below-


2. List all employee names , salary , 15% rise as ‘Raise’ and Rised amount
after 15% as Raised_Amount in salary.
3.. Insert the following record in employee table-
(6,’ ‘, HR,2345,12-12-2020, 45000,40,20,32)
(7,George, Research,,2480,01-01-2018, 55000,’ ‘,25,42)
4. List ename, job where employee name is NULL
5.List ename whose manager is not NULL.
6. Find no.of dept in employee table.
7. List ename whose commission is NULL.
8. Display ename of the dept. with deptno 30.

Q6. Consider the visitor table data-

VisitorID VisitorName Gender ComingFrom AmountPaid

1 Suman F Kanpur 5000

2 Indu F Lucknow 4500

3 Rachana F Haryana 3000

4 Vikram M Kanpur 2000

5 Rajesh M Kanpur 4000

6 Suresh M Lucknow 3000

7 Dinesh M Varanasi

8 Shikha F Chandigarh 3600

Perform following operations on the above table

1. Create a table in which VisitorID will be an auto-increment column.


2. Insert data of VisitorName, Gender, ComingFrom and AmountPaid as shown in table.
3. Write a query to display VisitorName, Coming from details of Female Visitors with
Amount Paid more than 3500.
4. Write a query to fetch the data of those visitors whose AmountPaid is NULL.
5. Write a query to update the column name ‘COMINGFROM’ to ‘CITY’
6. Write a query to Delete the data from column ‘AmountPaid’.
7. Write a query to check the system date from the DUAL table.

You might also like