Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
12Activity
0 of .
Results for:
No results containing your search query
P. 1
More SQL Queries

More SQL Queries

Ratings: (0)|Views: 22 |Likes:
Published by durga_prasad11511

More info:

Published by: durga_prasad11511 on Dec 14, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less

10/13/2012

pdf

text

original

 
 SQL Queries
Ques 1.Design the following table:a)proj1999(projNo, loc, customer )Query:
SQL> create table proj1999 (2 projno Number(10),3 loc varchar2(10),4 customer varchar2(10),5 constraint proj1999_projno_pk primary key(projno)6 );Table created.
b) proj2000 (projno, loc, customer )Query:
SQL> create table proj2000(2 projno Number(10),3 loc varchar2(10),4 customer varchar2(10),5 constraint proj2000_projno_pk primary key(projno)6 );Table created.
c) parts(partno,partdesc,vendor,cost)Query:
SQL> create table parts(2 partno number(10),3 partdesc varchar2(10),4 vendor varchar2(10),5 cost number(4,2),6 constraint parts_partno_pk primary key(partno)7 );Table created.
d) department(deptno, deptname)Query:
SQL> create table department(2 deptno number(10),3 deptname varchar2(10),4 constraint department_deptno_pk primary key(deptno)5 );Table created.
 
e) employee(empno,ename,deptno,projno,salary)
SQL> create table employee(2 empno number(10),3 ename varchar2(10),4 deptno number(10),5 projno number(10),6 salary number(10),7 constraint employee_empno_pk primary key(empno),8 constraint employee_deptno_fk foreign key(deptno) references department(deptno),9 constraint employee_projno_1_fk foreign key(projno) references proj1999(projno),10 constraint employee_projno_2_fk foreign key(projno) references proj2000(projno)11 );Table created.
f) prjparts(projno,partno,qty)Query:
SQL> create table prjparts(2 projno Number(10),3 partno number(10),4 qty number(10),5 constraint prjparts_projno_1_fk foreign key(projno) references proj1999(projno),6 constraint prjparts_projno_2_fk foreign key(projno) references proj2000(projno),7 constraint prjparts_partno_fk foreign key(partno) references parts(partno),
 
8 constraint prjparts_projno_partno_pk primary key(projno,partno)9 );Table created.
2) Insert records into proj1999.Query:
SQL> insert into proj1999 values(&projno,'&loc','&customer');Enter value for projno: 1Enter value for loc: miamiEnter value for customer: socksold 1: insert into proj1999 values(&projno,'&loc','&customer')new 1: insert into proj1999 values(1,'miami','socks')1 row created.SQL> /Enter value for projno: 2Enter value for loc: orlandoEnter value for customer: allenold 1: insert into proj1999 values(&projno,'&loc','&customer')new 1: insert into proj1999 values(2,'orlando','allen')1 row created.SQL> /Enter value for projno: 3
 
Enter value for loc: trentonEnter value for customer: smithold 1: insert into proj1999 values(&projno,'&loc','&customer')new 1: insert into proj1999 values(3,'trenton','smith')1 row created.SQL> /Enter value for projno: 4Enter value for loc: charlotteEnter value for customer: jonesold 1: insert into proj1999 values(&projno,'&loc','&customer')new 1: insert into proj1999 values(4,'charlotte','jones')1 row created.
3
) Insert records into proj2000.Query:
SQL> insert into PROJ2002 values(&projno,'&loc','&customer');Enter value for projno: 1Enter value for loc: MiamiEnter value for customer: Stocksold 2: values(&projno,'&loc','&customer')new 2: values(1,'Miami','Stocks')1 row created.SQL> /Enter value for projno: 2Enter value for loc: /Enter value for customer:old 2: values(&projno,'&loc','&customer')new 2: values(2,'/','')1 row created.SQL> /Enter value for projno: 3Enter value for loc: TrentonEnter value for customer: Smithold 2: values(&projno,'&loc','&customer')new 2: values(3,'Trenton','Smith')1 row created.

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->