1 Oracle 8
2 New features
3 Oracle 8 New features Abstract data types New features Abstract data types
4 Oracle 8 New features Abstract data types Nested tables New features Abstract data types Nested tables
5 Oracle 8 New features Abstract data types Nested tables Varying arrays New features Abstract data types Nested tables Varying arrays
6 Oracle 8 New features Abstract data types Nested tables Varying arrays Large objects New features Abstract data types Nested tables Varying arrays Large objects
7 Oracle 8 New features Abstract data types Nested tables Varying arrays Large objects References New features Abstract data types Nested tables Varying arrays Large objects References
8 Oracle 8 New features Abstract data types Nested tables Varying arrays Large objects References Object views New features Abstract data types Nested tables Varying arrays Large objects References Object views
9 Oracle 8 Abstract data types
10 Oracle 8 Abstract data types CREATE TYPE statement CREATE TYPE ADDRESS_TYPE AS OBJECT (StreetVARCHAR2(50), CityVARCHAR2(25), StateVARCHAR(3), ZipNUMBER(4)); Abstract data types CREATE TYPE statement CREATE TYPE ADDRESS_TYPE AS OBJECT (StreetVARCHAR2(50), CityVARCHAR2(25), StateVARCHAR(3), ZipNUMBER(4));
11 Oracle 8 Abstract data types CREATE TYPE statement CREATE TYPE ADDRESS_TYPE AS OBJECT (StreetVARCHAR2(50), CityVARCHAR2(25), StateVARCHAR(3), ZipNUMBER(4)); CREATE TYPE PERSON_TYPE AS OBJECT (NameVARCHAR2(30), AddressADDRESS_TYPE); Abstract data types CREATE TYPE statement CREATE TYPE ADDRESS_TYPE AS OBJECT (StreetVARCHAR2(50), CityVARCHAR2(25), StateVARCHAR(3), ZipNUMBER(4)); CREATE TYPE PERSON_TYPE AS OBJECT (NameVARCHAR2(30), AddressADDRESS_TYPE);
12 Oracle 8 Abstract data types CREATE TABLE statement CREATE TABLE CUSTOMER (Customer_IDNUMBER(6), PersonPERSON_TYPE ); Abstract data types CREATE TABLE statement CREATE TABLE CUSTOMER (Customer_IDNUMBER(6), PersonPERSON_TYPE );
13 Oracle 8 Abstract data types CREATE TABLE statement CREATE TABLE CUSTOMER (Customer_IDNUMBER(6), PersonPERSON_TYPE ); CREATE TABLE DEPARTMENT (Dept_NameVARCHAR2(20), AddressADDRESS_TYPE)); Abstract data types CREATE TABLE statement CREATE TABLE CUSTOMER (Customer_IDNUMBER(6), PersonPERSON_TYPE ); CREATE TABLE DEPARTMENT (Dept_NameVARCHAR2(20), AddressADDRESS_TYPE));
14 Oracle 8 Abstract data types INSERT INTO statement INSERT INTO CUSTOMER VALUES ( 1, PERSON_TYPE(‘Mike Jones’, ADDRESS_TYPE(‘Penny St.’, ‘London’, ‘HK’, 1234))); Abstract data types INSERT INTO statement INSERT INTO CUSTOMER VALUES ( 1, PERSON_TYPE(‘Mike Jones’, ADDRESS_TYPE(‘Penny St.’, ‘London’, ‘HK’, 1234)));
15 Oracle 8 Abstract data types INSERT INTO statement INSERT INTO CUSTOMER VALUES ( 1, PERSON_TYPE(‘Mike Jones’, ADDRESS_TYPE(‘Penny St.’, ‘London’, ‘HK’, 1234))); INSERT INTO DEPARTMENT VALUES( ‘SITACS’, ADDRESS_TYPE(‘Northfields Ave.’, ‘Wollongong’, ‘NSW’, 2522) ); Abstract data types INSERT INTO statement INSERT INTO CUSTOMER VALUES ( 1, PERSON_TYPE(‘Mike Jones’, ADDRESS_TYPE(‘Penny St.’, ‘London’, ‘HK’, 1234))); INSERT INTO DEPARTMENT VALUES( ‘SITACS’, ADDRESS_TYPE(‘Northfields Ave.’, ‘Wollongong’, ‘NSW’, 2522) );
16 Oracle 8 Abstract data types SELECT statement –SELECT Customer_id, Person.Name –FROM Customer –WHERE Person.Address.City = ‘London’; –SELECT * –FROM Department; Abstract data types SELECT statement –SELECT Customer_id, Person.Name –FROM Customer –WHERE Person.Address.City = ‘London’; –SELECT * –FROM Department;
17 Oracle 8 Abstract data types DROP TYPE statement DROP TYPE PERSON_TYPE Abstract data types DROP TYPE statement DROP TYPE PERSON_TYPE
18 Oracle 8 Abstract data types DROP TYPE statement DROP TYPE PERSON_TYPE CREATE OR REPLACE TYPE statement CREATE OR REPLACE TYPE ADDRESS_TYPE AS OBJECT (StreetVARCHAR2(50), CityVARCHAR2(25) ); Abstract data types DROP TYPE statement DROP TYPE PERSON_TYPE CREATE OR REPLACE TYPE statement CREATE OR REPLACE TYPE ADDRESS_TYPE AS OBJECT (StreetVARCHAR2(50), CityVARCHAR2(25) );
19 Oracle 8 Indexing abstract data type attributes
20 Oracle 8 Indexing abstract data type attributes CREATE INDEX statement CREATE INDEX CUST_IDX ON Customer(Person.Address.City) ; Indexing abstract data type attributes CREATE INDEX statement CREATE INDEX CUST_IDX ON Customer(Person.Address.City) ;
21 Oracle 8 Object views
22 Oracle 8 Object views CREATE TABLE CUSTOMER (Customer_IdNUMBER(6) PRIMARY KEY, NameVARCHAR2(30), StreetVARCHAR2(50), CityVARCHAR2(20), StateCHAR(3), ZipNUMBER(4)); Object views CREATE TABLE CUSTOMER (Customer_IdNUMBER(6) PRIMARY KEY, NameVARCHAR2(30), StreetVARCHAR2(50), CityVARCHAR2(20), StateCHAR(3), ZipNUMBER(4));
23 Oracle 8 Object views CREATE TYPE ADDRESS_TYPE AS OBJECT StreetVARCHAR2(50), CityVARCHAR2(20), StateCHAR(3), ZipNUMBER(4)); Object views CREATE TYPE ADDRESS_TYPE AS OBJECT StreetVARCHAR2(50), CityVARCHAR2(20), StateCHAR(3), ZipNUMBER(4));
24 Oracle 8 Object views CREATE TYPE ADDRESS_TYPE AS OBJECT StreetVARCHAR2(50), CityVARCHAR2(20), StateCHAR(3), ZipNUMBER(4)); CREATE TYPE PERSON_TYPE AS OBJECT (NameVARCHAR2(30), AddressADDRESS_TYPE); Object views CREATE TYPE ADDRESS_TYPE AS OBJECT StreetVARCHAR2(50), CityVARCHAR2(20), StateCHAR(3), ZipNUMBER(4)); CREATE TYPE PERSON_TYPE AS OBJECT (NameVARCHAR2(30), AddressADDRESS_TYPE);
25 Oracle 8 Object views CREATE VIEW CUSTOMER_V (Customer_ID, Person) AS SELECT Customer_ID, PERSON_TYPE(Name, ADDRESS_TYPE(Street, City, State,Zip) ) FROMCUSTOMER WHEREState = ‘NSW’; Object views CREATE VIEW CUSTOMER_V (Customer_ID, Person) AS SELECT Customer_ID, PERSON_TYPE(Name, ADDRESS_TYPE(Street, City, State,Zip) ) FROMCUSTOMER WHEREState = ‘NSW’;
26 Oracle 8 Object views Create flat relational table Object views Create flat relational table
27 Oracle 8 Object views Create flat relational table Create abstract data types Object views Create flat relational table Create abstract data types
28 Oracle 8 Object views Create flat relational table Create abstract data types Create object view Object views Create flat relational table Create abstract data types Create object view
29 Oracle 8 Methods
30 Oracle 8 Methods CREATE TYPE PERSON_TYPE AS OBJECT (NameVARCHAR2(30), AddressADDRESS_TYPE, BithDateDATE, MEMBER FUNCTION Age( BirthDate IN DATE) RETURN NUMBER ); Methods CREATE TYPE PERSON_TYPE AS OBJECT (NameVARCHAR2(30), AddressADDRESS_TYPE, BithDateDATE, MEMBER FUNCTION Age( BirthDate IN DATE) RETURN NUMBER );
31 Oracle 8 Methods CREATE TYPE BODY PERSON_TYPE AS MEMBER FUNCTION Age( BirthDate IN DATE) RETURN NUMBER IS BEGIN RETURN ROUND(SysDate - BirthDate); END; / Methods CREATE TYPE BODY PERSON_TYPE AS MEMBER FUNCTION Age( BirthDate IN DATE) RETURN NUMBER IS BEGIN RETURN ROUND(SysDate - BirthDate); END; /
32 Oracle 8 Methods CREATE TABLE STUDENT (SIDNUMBER(6), PERSONPERSON_TYPE ); SELECT STUDENT.Age(Student.BirthDate) FROM STUDENT; Methods CREATE TABLE STUDENT (SIDNUMBER(6), PERSONPERSON_TYPE ); SELECT STUDENT.Age(Student.BirthDate) FROM STUDENT;
33 Oracle 8 Collectors
34 Oracle 8 Collectors Varying arrays Collectors Varying arrays
35 Oracle 8 Collectors Varying arrays Nested tables Collectors Varying arrays Nested tables
36 Oracle 8 Varying arrays
37 Oracle 8 Varying arrays CREATE TYPE TOOL_TYPE AS OBJECT (ToolNameVARCHAR2(30) ); Varying arrays CREATE TYPE TOOL_TYPE AS OBJECT (ToolNameVARCHAR2(30) );
38 Oracle 8 Varying arrays CREATE TYPE TOOL_TYPE AS OBJECT (ToolNameVARCHAR2(30) ); CREATE TYPE TOOLS_VA AS VARRAY(5) OF TOOL_TYPE; Varying arrays CREATE TYPE TOOL_TYPE AS OBJECT (ToolNameVARCHAR2(30) ); CREATE TYPE TOOLS_VA AS VARRAY(5) OF TOOL_TYPE;
39 Oracle 8 Varying arrays CREATE TYPE TOOL_TYPE AS OBJECT (ToolNameVARCHAR2(30) ); CREATE TYPE TOOLS_VA AS VARRAY(5) OF TOOL_TYPE; CREATE TABLE MECHANIC (NameVARCHAR2(30) PRIMARY KEY, ToolsTOOLS_VA ); Varying arrays CREATE TYPE TOOL_TYPE AS OBJECT (ToolNameVARCHAR2(30) ); CREATE TYPE TOOLS_VA AS VARRAY(5) OF TOOL_TYPE; CREATE TABLE MECHANIC (NameVARCHAR2(30) PRIMARY KEY, ToolsTOOLS_VA );
40 Oracle 8 Varying arrays INSERT INTO MECHANIC VALUES (‘Mike Jones’, TOOLS_VA(TOOL_TYPE(‘HAMMER’), TOOL_TYPE(‘SLEDGE’), TOOL_TYPE(‘AX’))); Varying arrays INSERT INTO MECHANIC VALUES (‘Mike Jones’, TOOLS_VA(TOOL_TYPE(‘HAMMER’), TOOL_TYPE(‘SLEDGE’), TOOL_TYPE(‘AX’)));
41 Oracle 8 Varying arrays DECLARE CURSOR MECHANIC_CURSOR IS SELECT * FROM MECHANIC; MECHANIC_REC MECHANIC_CURSOR%ROWTYPE; BEGIN FOR MECHANIC_REC IN MECHANIC_CURSOR LOOP DBMS_OUTPUT.PUT_LINE(MECHANIC_REC.Name); FOR I IN 1..MECHANIC_REC.Tools.Count LOOP DBMS_OUTPUT.PUT_LINE(MECHANIC_REC.Tools(I)); END LOOP; END; Varying arrays DECLARE CURSOR MECHANIC_CURSOR IS SELECT * FROM MECHANIC; MECHANIC_REC MECHANIC_CURSOR%ROWTYPE; BEGIN FOR MECHANIC_REC IN MECHANIC_CURSOR LOOP DBMS_OUTPUT.PUT_LINE(MECHANIC_REC.Name); FOR I IN 1..MECHANIC_REC.Tools.Count LOOP DBMS_OUTPUT.PUT_LINE(MECHANIC_REC.Tools(I)); END LOOP; END;
42 Oracle 8 Nested tables
43 Oracle 8 Nested tables CREATE TYPE ANIMAL_TYPE AS OBJECT (BreedVARCHAR2(30), NameVARCHAR2(20), BirthdateDATE ); Nested tables CREATE TYPE ANIMAL_TYPE AS OBJECT (BreedVARCHAR2(30), NameVARCHAR2(20), BirthdateDATE );
44 Oracle 8 Nested tables CREATE TYPE ANIMAL_TYPE AS OBJECT (BreedVARCHAR2(30), NameVARCHAR2(20), BirthdateDATE ); CREATE TYPE ANIMAL_TABLE AS TABLE OF ANIMAL_TYPE; Nested tables CREATE TYPE ANIMAL_TYPE AS OBJECT (BreedVARCHAR2(30), NameVARCHAR2(20), BirthdateDATE ); CREATE TYPE ANIMAL_TABLE AS TABLE OF ANIMAL_TYPE;
45 Oracle 8 Nested tables CREATE TYPE ANIMAL_TYPE AS OBJECT (BreedVARCHAR2(30), NameVARCHAR2(20), BirthdateDATE ); CREATE TYPE ANIMAL_TABLE AS TABLE OF ANIMAL_TYPE; CREATE TABLE BREEDER (BreederNameVARCHAR2(30), AnimalsANIMAL_TABLE) NESTED TABLE ANIMALS STORE AS ANIMALS_NT; Nested tables CREATE TYPE ANIMAL_TYPE AS OBJECT (BreedVARCHAR2(30), NameVARCHAR2(20), BirthdateDATE ); CREATE TYPE ANIMAL_TABLE AS TABLE OF ANIMAL_TYPE; CREATE TABLE BREEDER (BreederNameVARCHAR2(30), AnimalsANIMAL_TABLE) NESTED TABLE ANIMALS STORE AS ANIMALS_NT;
46 Oracle 8 Nested tables INSERT INTO BREEDER VALUES (‘Mike Jones’, ANIMAL_TABLE( ANIMAL_TYPE( ‘DOG’, ‘BUTCH’, ‘31-MAR-97’), ANIMAL_TYPE( ‘CAT’, ‘ROVER’, ‘1-MAR-98’), ANIMAL_TYPE( ‘RAT’, ‘JULIO’, 12-MAR-79’) ) ); Nested tables INSERT INTO BREEDER VALUES (‘Mike Jones’, ANIMAL_TABLE( ANIMAL_TYPE( ‘DOG’, ‘BUTCH’, ‘31-MAR-97’), ANIMAL_TYPE( ‘CAT’, ‘ROVER’, ‘1-MAR-98’), ANIMAL_TYPE( ‘RAT’, ‘JULIO’, 12-MAR-79’) ) );
47 Oracle 8 Nested tables SELECT NT.BirthDate FROM THE(SELECTAnimals FROMBREEDER WHEREBreederName = ‘Jane James’; ) NT WHERE NT.name = ‘Julio’; Nested tables SELECT NT.BirthDate FROM THE(SELECTAnimals FROMBREEDER WHEREBreederName = ‘Jane James’; ) NT WHERE NT.name = ‘Julio’;
48 Oracle 8 Nested tables INSERT INTO THE(SELECTAnimals FROMBREEDER WHEREBreederName =‘Mike Jones’) VALUES (ANIMAL_TYPE( ‘DOG, ‘MARCUS’, ‘01-AUG-97’) ); Nested tables INSERT INTO THE(SELECTAnimals FROMBREEDER WHEREBreederName =‘Mike Jones’) VALUES (ANIMAL_TYPE( ‘DOG, ‘MARCUS’, ‘01-AUG-97’) );
49 Oracle 8 Nested tables INSERT INTO BREEDER VALUES (‘Joan Thomas’, cast(multiset( SELECT * FROM THE(SELECTAnimals FROMBREEDER WHEREBreederName = ‘Jane James’)) AS ANIMAL_TABLE ) ); Nested tables INSERT INTO BREEDER VALUES (‘Joan Thomas’, cast(multiset( SELECT * FROM THE(SELECTAnimals FROMBREEDER WHEREBreederName = ‘Jane James’)) AS ANIMAL_TABLE ) );
50 Oracle 8 Object tables
51 Oracle 8 Object tables CREATE TYPE ANIMAL_TYPE AS OBJECT (BreedVARCHAR2(30), NameVARCHAR2(20), BirthdateDATE ); CREATE TABLE ANIMAL OF ANIMAL_TYPE; Object tables CREATE TYPE ANIMAL_TYPE AS OBJECT (BreedVARCHAR2(30), NameVARCHAR2(20), BirthdateDATE ); CREATE TABLE ANIMAL OF ANIMAL_TYPE;
52 Oracle 8 REF operator
53 Oracle 8 REF operator SELECTREF(A) FROM ANIMAL A WHEREName = ‘Francis’; REF operator SELECTREF(A) FROM ANIMAL A WHEREName = ‘Francis’;
54 Oracle 8 DEREF operator
55 Oracle 8 DEREF operator CREATE TABLE ANIMAL OF ANIMAL_TYPE; CREATE TABLE KEEPER (KeeperNameVARCHAR2(30), AnimalKeptREF ANIMAL_TYPE ) DEREF operator CREATE TABLE ANIMAL OF ANIMAL_TYPE; CREATE TABLE KEEPER (KeeperNameVARCHAR2(30), AnimalKeptREF ANIMAL_TYPE )
56 Oracle 8 DEREF operator CREATE TABLE ANIMAL OF ANIMAL_TYPE; CREATE TABLE KEEPER (KeeperNameVARCHAR2(30), AnimalKeptREF ANIMAL_TYPE ) INSERT INTO KEEPER SELECT ‘Kate’, REF(A) FROM ANIMAL A WHERE Name = ‘Benji’; DEREF operator CREATE TABLE ANIMAL OF ANIMAL_TYPE; CREATE TABLE KEEPER (KeeperNameVARCHAR2(30), AnimalKeptREF ANIMAL_TYPE ) INSERT INTO KEEPER SELECT ‘Kate’, REF(A) FROM ANIMAL A WHERE Name = ‘Benji’;
57 Oracle 8 DEREF operator SELECT DEREF(K.AnimalKept) FROM KEEPER K WHERE KeeperName = ‘Kate’; DEREF operator SELECT DEREF(K.AnimalKept) FROM KEEPER K WHERE KeeperName = ‘Kate’;
58 Oracle 8 VALUE operator
59 Oracle 8 VALUE operator SELECT VALUE(A) FROM ANIMAL A WHERE NAME = ‘Benji’; VALUE operator SELECT VALUE(A) FROM ANIMAL A WHERE NAME = ‘Benji’;
60 Oracle 8 Generation of OIDs CREATE TYPE CUSTOMER_TYPE AS OBJECT (Customer_IDNUMBERPRIMARY KEY, NameVARCHAR(30), StreetVARCHAR2(20), CityVARCHAR2(20), StateCHAR(3) ZipNUMBER(4)); CREATE VIEW CUSTOMER_OBJ OF CUSTOMER_TYPE WITH OBJECT OID(Customer_ID) AS SELECT * FROM Customer; Generation of OIDs CREATE TYPE CUSTOMER_TYPE AS OBJECT (Customer_IDNUMBERPRIMARY KEY, NameVARCHAR(30), StreetVARCHAR2(20), CityVARCHAR2(20), StateCHAR(3) ZipNUMBER(4)); CREATE VIEW CUSTOMER_OBJ OF CUSTOMER_TYPE WITH OBJECT OID(Customer_ID) AS SELECT * FROM Customer;
61 Oracle 8 Generation of OIDs CREATE VIEW CUSTOMER_CALL_OBJ AS SELECT MAKE_REF(CUSTOMER_OBJECT, Customer ID) Customer_ID, CallNumber, CallDate FROM Customer_Call; Generation of OIDs CREATE VIEW CUSTOMER_CALL_OBJ AS SELECT MAKE_REF(CUSTOMER_OBJECT, Customer ID) Customer_ID, CallNumber, CallDate FROM Customer_Call;
62 Oracle 8 Generation of OIDs SELECT DEREF(CCOV.Customer_ID) FROM CUSTOMER_CALL_OBJECT WHERE CallDate = TRUNC(SysDate); Generation of OIDs SELECT DEREF(CCOV.Customer_ID) FROM CUSTOMER_CALL_OBJECT WHERE CallDate = TRUNC(SysDate);
63 Oracle 8 Large Objects
64 Oracle 8 Large Objects BLOB Binary LOB. It contains binary data up to 4GB in length and it is stored in the database Large Objects BLOB Binary LOB. It contains binary data up to 4GB in length and it is stored in the database
65 Oracle 8 Large Objects BLOB Binary LOB. It contains binary data up to 4GB in length and it is stored in the database CLOB Character LOB. It contains character data up to 4GB in length and it is stored in the database Large Objects BLOB Binary LOB. It contains binary data up to 4GB in length and it is stored in the database CLOB Character LOB. It contains character data up to 4GB in length and it is stored in the database
66 Oracle 8 Large Objects BLOB Binary LOB. It contains binary data up to 4GB in length and it is stored in the database CLOB Character LOB. It contains character data up to 4GB in length and it is stored in the database BFILE Binary file. It contains read-only binary data stored outside the database and its length is limited by operating system Large Objects BLOB Binary LOB. It contains binary data up to 4GB in length and it is stored in the database CLOB Character LOB. It contains character data up to 4GB in length and it is stored in the database BFILE Binary file. It contains read-only binary data stored outside the database and its length is limited by operating system
67 Oracle 8 Large Objects CREATE TABLE Proposal (Proposal_IDNUMBER(10) PRIMARY KEY, NameVARCHAR2(30), ShortDescriptionVARCHAR2(1000), ProposalTextCLOB, BudgetBLOB, CoverLetterBFILE ); Large Objects CREATE TABLE Proposal (Proposal_IDNUMBER(10) PRIMARY KEY, NameVARCHAR2(30), ShortDescriptionVARCHAR2(1000), ProposalTextCLOB, BudgetBLOB, CoverLetterBFILE );
68 Oracle 8 Large Objects INSERT INTO Proposal VALUES ( 123, ‘Nuclear reactor’, ‘This is a short decription’, ‘This is a text of full proposal’, EMPTY_BLOB(), NULL); Large Objects INSERT INTO Proposal VALUES ( 123, ‘Nuclear reactor’, ‘This is a short decription’, ‘This is a text of full proposal’, EMPTY_BLOB(), NULL);
69 Oracle 8 DBMS_LOB package READ Read a pice of a LOB value SUBSTR Select a piece of a LOB value INSTR Insert a piece of a LOB value GETLENGHT Find the length of a LOB value DBMS_LOB package READ Read a pice of a LOB value SUBSTR Select a piece of a LOB value INSTR Insert a piece of a LOB value GETLENGHT Find the length of a LOB value
70 Oracle 8 DBMS_LOB package COMPARE Compare two LOB values WRITE Write a piece of a LOB value APPEND Append a piece of a LOB value ERASE Erase a piece of a LOB value DBMS_LOB package COMPARE Compare two LOB values WRITE Write a piece of a LOB value APPEND Append a piece of a LOB value ERASE Erase a piece of a LOB value
71 Oracle 8 References /share/cs-pub/235/docs/SQLRef.pdf /share/cs-pub/235/docs/PLSQLRef.pdf References /share/cs-pub/235/docs/SQLRef.pdf /share/cs-pub/235/docs/PLSQLRef.pdf