sql exercise

 SQL Exercises -1

Exercise 1. Create a table ‘Busroute’ with following structure and insert the given rows.
Table name: Busroute

Fields:

Route_id
number (3) (This table contains the details of the Places and distance the  bus is traveling)
Route no
Number (2)
Buscode
Number (2)
Origin
Varchar2 (20)
Fare
Number (6)
Dist
Number (3)
Capacity
Number (2)



Route_id
Route_no
Buscode
Origin
Dest
Fare
Dist
Capacity
201
33
01
Madurai
Chennai
170
300
45
202
25
02
Trichy
Madurai
45
100
50
203
15
03
Nellai
Madurai
30
90
50
204
36
04
Chennai
Bangalore
150
250
55
205
40
01
Bangalore
Madurai
170
250
45
206
38
02
Chennai
Madurai
160
300
50
207
39
03
Hyderabad
Chennai
160
190
50
208
41
04
Chennai
Chochin
148
320
50
209
47
02
Chennai
Coimbatore
165
300
50
210
46
04
Coimbatore
Chennai
150
300
55


 
Solution: 

Create table Busroute (Route_id number (3), Route_no number (2), Buscode number (2), Origin varchar2 (10), Dest varchar2 (20), Fare number (6), Dist number (3), Capacity number (2));
Insert into Busroute values (201, 33, 01, Madurai, Chennai, 170, 300, 45);
Insert into Busroute values (202, 25, 02, ‘Trichy’, ‘Madurai’, 45, 100, 50);
(Follow the above procedure to insert the rest of the rows). 


 
Exercise 2. List all the contents of busroute table.

Solution: 
Select * from Busroute;

Exercise 3. Display the structure of the busroute table. 
Solution: 
Desc Busroute;

 

Comments