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

Q3SQL PRACTICAL

The document outlines the creation of several SQL tables including CUSTOMER, BicycleModel, BICYCLE, and SERVICE, along with their respective fields and constraints. It includes sample data for each table and various SQL SELECT queries demonstrating how to retrieve information based on specific conditions. The queries illustrate relationships between the tables, such as retrieving customer details for bicycles of a certain manufacturer and filtering by color.

Uploaded by

lodhpoojitha7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Q3SQL PRACTICAL

The document outlines the creation of several SQL tables including CUSTOMER, BicycleModel, BICYCLE, and SERVICE, along with their respective fields and constraints. It includes sample data for each table and various SQL SELECT queries demonstrating how to retrieve information based on specific conditions. The queries illustrate relationships between the tables, such as retrieving customer details for bicycles of a certain manufacturer and filtering by color.

Uploaded by

lodhpoojitha7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL> create table CUSTOMER(CUSTID VARCHAR2(2),

EMAIL VARCHAR2(15),
NAME VARCHAR2(20),
PHONE NUMBER(10),
REFERREDID VARCHAR2(2),
CONSTRAINT PK1 PRIMARY KEY(CUSTID));

SQL> select * from customer;

CUSTID EMAIL NAME PHONE REFERRE


------ --------------- -------------------- --------- -------
C1 [email protected] shoeb 12345674 R1
C2 [email protected] zuber 23456789 R2
C3 [email protected] vara 34567890 R3
C4 [email protected] venky 45678932 R4
C5 [email protected] adil 98746523 R5

SQL> create table BicycleModel(ModelNo varchar2(10) primary key, Manufacturer


varchar2(10), Style varchar2(10));

SQL> SELECT * FROM BICYCLEMODEL;

MODELNO MANUFACTUR STYLE


---------- ---------- ----------
M1 HONDA CB
M2 YAMAHA FZ25
M3 HONDA CBR
M4 YAMAHA
M5 HERO SPLENDER

SQL> CREATE TABLE BICYCLE(BICYCLEID VARCHAR2(10) PRIMARY KEY, DOP


DATE, COLOR VARCHAR2(7),CUSTID VARCHAR2(6) REFERENCES
CUSTOMER(CUSTID),MODELNO VARCHAR2(10) REFERENCES
BICYCLEMODEL(MODELNO));
SQL> SELECT * FROM BICYCLE;

BICYCLEID DOP COLOR CUSTID MODELNO


---------- --------- ------- ------ ----------
B1 02-JUL-17 BLACK C1 M1
B2 01-JUN-96 RED C2 M2
B3 05-NOV-01 GREY C3 M3
B4 04-AUG-15 BLACK C4 M4
B5 04-JUN-18 RED C5 M5

SQL> CREATE TABLE SERVICE ( STARTDATE DATE, BICYCLEID VARCHAR2(10)


REFERENCES BICYCLE(BICYCLEID), ENDDATE DATE, PRIMARY KEY (STARTDATE,
BICYCLEID))

SQL> SELECT * FROM SERVICE;

STARTDATE BICYCLEID ENDDATE


--------- ---------- ---------
11-JUN-17 B1 13-OCT-17
10-SEP-96 B2 12-SEP-96
07-MAR-02 B3 09-MAR-02
08-NOV-15 B4 10-NOV-15
22-AUG-18 B5 24-AUG-18

B). SELECT C.CUSTID, NAME, C.PHONE, M.MANUFACTURER FROM CUSTOMER C,


BICYCLE B, BICYCLEMODEL M WHERE C.CUSTID=B.CUSTID AND
B.MODELNO=M.MODELNO AND M.MANUFACTURER='HONDA'

OUT PUT:
CUSTID NAME PHONE MANUFACTUR
------ -------------------- --------- ----------
C1 shoeb 12345674 HONDA
C3 vara 34567890 HONDA
C) SELECT * FROM CUSTOMER C, BICYCLE B WHERE C.CUSTID=B.CUSTID AND
B.CUSTID='C1'

OUTPUT:
CUST BICYCLE CUST MODEL
ID EMAIL NAME PHONE REFERRE ID DOP COLOR ID NO
C1 [email protected] shoeb 12345674 R1 B1 2-Jul-17 BLACK C1 M1

D)
SELECT M.MANUFACTURER, B.COLOR FROM BICYCLE B, BICYCLEMODEL M
WHERE M.MODELNO=B.MODELNO AND B.COLOR='RED'

OUTPUT:
MANUFACTUR COLOR
---------- ------
YAMAHA RED
HERO RED

E)
SELECT M.MODELNO FROM BICYCLEMODEL M, SERVICE S, BICYCLE B WHERE
M.MODELNO=B.MODELNO AND B.BICYCLEID=S.BICYCLEID;

OUTPUT:
MODELNO
----------
M1
M2
M3
M4
M5

You might also like