Assignment 4
Assignment 4
3. Create a view 'vrr route header and route detail from route header and
route_detail with the following column: route_id, origin, destination, fare,
place id, non_stop.
6. Alter the sequence such that the max value would be 25.
2.
1 row updated.
3.
1 row updated.
4.
Sequence created.
7.
Index created.
SQL> COMMIT;
Commit complete.
ASSIGNMENT 4b
Q8. Select distinct numbers from both ticket_header and
ticket_detail.
Q9. Select all ticket numbers from ticket_header and
ticket_detail.
Q10. Select distinct route_id from route_header and not in
route_detail using both the tables.
Q11. Select all rows from route_header and only matching rows
from route_detail.
Q12. Select distinct route_ids from route_header and
route_detail.
Q13. Select only common place ids that are present in
place_header and route_detail.
Q14. Select common ticket numbers from ticket_header and
ticket_detail where the route ids are greater than the route_id
which belong to the place with iod ‘02’.
8.
TICKET_NO
----------
1
2
3
4
5
9.
SQL> (SELECT TICKET_NO FROM TICKET_HEADER) UNION ALL (SELECT TICKET_NO FROM
TICKET_DETAIL);
TICKET_NO
----------
2
3
4
1
1
2
2
2
5
10.
ROUTE_ID
----------
101
103
107
11.
no rows selected
12.
102 2 S
105 1 N
ROUTE_ID ROUTE_NUMBER CAT_CODE ORIGIN DESTINATION
---------- ------------ ---------- -------------------- --------------------
FARE DISTANCE CAPACITY
---------- ---------- ----------
COMMENTS
--------------------------------------------------------------------------------
ROUTE_ID PLACE_ID N
---------- ---------- -
106 38 2 Madras Madurai
39 300 50
106 1 S
108 5 N
13.
PLACE_ID
----------
1
2
5
14.
TICKET_NO
----------
2
SQL> COMMIT;
Commit complete.