MySQL Forums
Forum List  »  Oracle

Need help with Oracle SQL Quary
Posted by: saman kumara
Date: April 07, 2015 03:35AM

I am not good at for oracle sql. I need to fix my code. That is the problem. i given my answer. I want to check my code is correct or not. please help me.

Consider a type named student_type that has attributes, (sid: char(8), sname: varchar(15), phone: char(10)).
Let ug_type be a subtype of student_type with attributes, (gpa: real, deptid: char(6), course: varchar(10)).

(a) Write Oracle object SQL statements to create these two types.

(b) Assuming that a table named students of student_type has been created, insert ug_type tuple into it with attribute values of sid: 12354326, sname: Janet Paeres, phone: null, gpa: 3.2, deptid: CS01, and course:InfoTech.

(c) Assuming there may be data of ug_type and others in the table students of student_type, write an Oracleobject SQL statement to retrieve the sid and sname of only students with deptid of CS01.


My ANSWERS:
A)
CREATE TYPE student_type AS OBJECT (
sid char(8),
sname varchar(15),
phone char(10)) NOT FINAL;/

CREATE TABLE student_type_table of student_type(
sid PRIMARY KEY);

CREATE TYPE ug_type UNDER student_type
(gpa real,
deptid char(6),
course varchar(10));/

CREATE TABLE ug_type_table of ug_type;

B)
INSERT INTO student_type_table VALUES(
Student_type ('12354326', 'Janet Paeres', 'NULL'));

Insert into ug_type_table values(
Ug_type (3.2, 'CS01', 'InfoTech' ));


C)
How to do "C"?

Report message to a moderator

Options: ReplyQuote


Subject
Views
Written By
Posted
Need help with Oracle SQL Quary
1660
April 07, 2015 03:35AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.