Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.  Objects  Varray  Nested Table  Transaction Control Language(TCL)

Slides:



Advertisements
Similar presentations
Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.
Advertisements

SQL Rohit Khokher.
BACS 485—Database Management Advanced SQL Overview Advanced DDL, DML, and DCL Commands.
Virtual training week 4 structured query language (SQL)
Fall 2005 ICS184/EECS116 – Notes 08 1 ICS 184/EECS116: Introduction to Data Management Lecture Note 8 SQL: Structured Query Language -- DDL.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
SQL Components DML DDL DAL. Overview u Getting the records onto the disk - mapping u Managing disk space u SQL Modes u Ceating database.
©Silberschatz, Korth and Sudarshan4.1Database System Concepts Modification of the Database – Deletion Delete all account records at the Perryridge branch.
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
5 Chapter 5 Structured Query Language (SQL1) Revision.
Structured Query Language. Brief History Developed in early 1970 for relational data model: –Structured English Query Language (SEQUEL) –Implemented with.
SQL Overview Defining a Schema CPSC 315 – Programming Studio Spring 2008 Project 1, Lecture 3 Slides adapted from those used by Jeffrey Ullman, via Jennifer.
Oracle Data Definition Language (DDL)
Structured Query Language S Q L. What is SQL It is a database programming language developed by IBM in the early 1970’s. It is used for managing and retrieving.
SQL Overview Defining a Schema CPSC 315 – Programming Studio Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch Via Yoonsuck Choe.
Structured Query Language (SQL) A2 Teacher Up skilling LECTURE 2.
Introduction to DBMS and SQL Introduction to DBMS and SQL GUIDED BY : MR. YOGESH SAROJ (PGT-CS) MR. YOGESH SAROJ (PGT-CS) Presented By : JAYA XII –COM.
o At the end of this lesson, you will be able to:  Describe the life-cycle development phases  Discuss the theoretical and physical aspects of a relational.
PL/SQLPL/SQL Oracle10g Developer: PL/SQL Programming Chapter 11 Introduction to Dynamic SQL and Object Technology.
Structured Query Language. Brief History Developed in early 1970 for relational data model: –Structured English Query Language (SEQUEL) –Implemented with.
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Application Development For DBA’s Lecture 8 Copyright System Managers LLC 2007 all rights reserved.
1 Advanced Databases (CM036): Lecture # 5 ( Object-Relational and Nested-Relational Databases) Introduction to Object-Relational features of Oracle 9i.
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Chapter 5: Part 1: DDL STRUCTURED QUERY LANGUAGE (SQL)
PL/SQL A BRIEF OVERVIEW DAVID WILSON. PL/SQL User’s Guide and Reference PL/SQL User’s Guide and Reference.
1 ICS 184: Introduction to Data Management Lecture Note 11: Assertions, Triggers, and Index.
ACTION QUERIES (SQL COMMANDS ) STRUCTURED QUERY LANGUAGE.
SQL FUNDAMENTALS SQL ( Structured Query Language )
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
10 Creating and Managing Tables Objectives At the end of this lesson, you will be able to: Describe the main database objects Create tables Describe.
10-1 Copyright  Oracle Corporation, All rights reserved. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns.
Nitin Singh/AAO RTI ALLAHABAD 1 SQL Nitin Singh/AAO RTI ALLAHABAD 2 OBJECTIVES §What is SQL? §Types of SQL commands and their function §Query §Index.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
Session 2: SQL (A): Parts 1 and 2 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
Tables and Constraints Oracle PL/SQL. Datatypes The SQL Data Definition Language Commands (or DDL) enable us to create, modify and remove database data.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
SQL: Part 1 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram. Not for commercial.
1 SQL-2 Tarek El-Shishtawy Professor Ass. Of Computer Engineering.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Introduction Object Oriented (OO) Data Models since mid-90’s Reasons for creation of.
An Introduction To SQL Part 2 (Special thanks to Geoff Leese)
1 Information Retrieval and Use (IRU) An Introduction To SQL Part 2.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
1 Announcements Reading for next week: Chapter 4 Your first homework will be assigned as soon as your database accounts have been set up.  Expect an .
Transactions, Roles & Privileges Oracle and ANSI Standard SQL Lecture 11.
Creating and Managing Tables 14. ObjectivesObjectives After completing this lesson, you should be able to do the following: After completing this lesson,
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Oracle & SQL. Oracle Data Types Character Data Types: Char(2) Varchar (20) Clob: large character string as long as 4GB Bolb and bfile: large amount of.
SLIDE 1IS 257 – Fall 2014 NoSQL Databases University of California, Berkeley School of Information IS 257: Database Management.
Introduction to PL/SQL Francis Thottungal. The outline The basic PL/SQL code structure is : DECLARE -- optional, which declares and define variables,
CSCI N311: Oracle Database Programming 5-1 Chapter 15: Changing Data: insert, update, delete Insert Rollback Commit Update Delete Insert Statement –Allows.
1 Part IV: Object-Relational Databases  Ch. 30: Types, Object Views, Methods  Ch. 31: Nested Tables and Varying Arrays  Ch. 32: Large Objects  Ch.
LECTURE FOUR Introduction to SQL DDL with tables DML with tables.
8 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects.
CSE 4701 Chapter 10-1 Chapter 10 6e: Oracle Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University of Connecticut 191.
SQL Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database.
Big Data Yuan Xue CS 292 Special topics on.
Chapter 5 Introduction to SQL.
TABLES AND INDEXES Ashima Wadhwa.
Interacting with the Oracle Server
STRUCTURED QUERY LANGUAGE
SQL OVERVIEW DEFINING A SCHEMA
Data Control Language Grant, Revoke.
Oracle Data Definition Language (DDL)
Object-Relational Features
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Database Programming Using Oracle 11g
SQL (Structured Query Language)
Presentation transcript:

Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha

 Objects  Varray  Nested Table  Transaction Control Language(TCL)

 User-Defined types  Advantage:  Encapsulate operations along with data  Are efficient  Can represent Part-Whole relationships

CREATE TYPE t AS OBJECT ( list of attributes and methods ); / CREATE TYPE PointType AS OBJECT ( X NUMBER, Y NUMBER ); /

CREATE TYPE Address_Ty AS OBJECT ( Street VARCHAR(20), City VARCHAR(20), State CHAR(2), Zip NUMBER ); CREATE TYPE Person_Ty AS OBJECT( Name VARCHAR(25), Address Address_Ty );

CREATE TABLE Customer( CustomerID NUMBER, Person Person_Ty ); INSERT INTO Customer VALUES (1, Person_Ty(‘Chris’, Address_Ty(…)));

SELECT Name FROM Customer; SELECT C.Person.Name FROM Customer C;

Alice: GRANT EXECUTE ON Address_Ty to Bob; Bob: CREATE TYPE Person_Ty as Object( Name VARCHAR(25), Address Alice.Address_Ty );

 Method  Are functions or procedures that you can declare in an object type definition SELECT c.contact.get_idno() FROM contacts c

CREATE TYPE LineType AS OBJECT( end1 PointType, end2 PointType, MEMBER FUNCTION length(scale NUMBER) RETURN NUMBER ); CREATE TYPE PointType AS OBJECT( X NUMBER, Y NUMBER, );

CREATE TYPE BODY LineType AS MEMBER FUNCTION lengh(scale NUMBER) RETURN NUMBER IS BEGIN RETURN scale * SQRT((SELF.end1.x – SELF.end2.x) * (SELF.end1.x – SELF.end2.x) + (SELF.end1.y – SELF.end2.y) * (SELF.end1.y – SELF.end2.y) ); END; /

CREATE TABLE Lines( LineID INT, Line LineType ;) INSERT INTO Lines VALUES (27, LineType( PointType (0.0, 0.0), PointType(3.0, 4.0) ) );

INSERT INTO Lines VALUES (27, LineType( PointType (0.0, 0.0), PointType(3.0, 4.0) ) ); SELECT lineID, ll.line.length(2.0) FROM Lines ll; lineID ll.line.length 27 10

DROP TYPE LineType; We must first drop the table Lines

 ALTER Type  Add and drop attributes  Add and drop methods  Modify a numeric attribute to increase its length, precision, or scale  Modify a varying length character attribute to increase its length

CREATE TYPE phone_t AS OBJECT( a_code CHAR(3), p_number CHAR(8) ); ALTER TYPE phone_t ADD ATTRIBUTE (countycode CHAR(3));

 An ordered set of data elements CREATE TYPE _list_arr AS VARRAY(10) of VARCHAR2(80) Index Data Type

CREATE TABLE Borrower( Name VARCHAR(25), Book VARCHAR(25), Constraint Borrower_PK primary key (Name, Book) ); CREATE TYPE Books_VA AS Varray(5) of VARCHAR(25); Book Books_VA INSERT INTO Borrower VALUES( ‘Bob’, Books_VA(‘Books1’, ‘Books2’);

CREATE TYPE Book_ty AS OBJECT( BookName VARCHAR(25), ISBN NUMBER); CREATE TYPE Books_VA AS Varray(5) of Book_ty; CREATE TABLE Borrower( Name VARCHAR(25), Book Books_VA, Constraint Borrower_PK primary key (Name, Book) );

CREATE TYPE phone_ty AS OBJECT ( country_code VARCHAR2(2), area_code VARCHAR2(3), ph_number VARCHAR2(7) ); CREATE TYPE phone_varray_ty AS VARRAY(5) OF phone_ty; CREATE TABLE dept_phone_list ( dept_no NUMBER(5), phone_list phone_varray_ty );

INSERT INTO dept_phone_list VALUES ( 100, phone_varray_ty( phone_ty ('01', '650', ' '), phone_ty ('01', '650', ' '), phone_ty ('01', '650', ' ') ) );

 An unordered set of data elements  No maximum is specified

CREATE TYPE project_type AS OBJECT ( name VARCHAR2(50), role VARCHAR2(20) ); CREATE TYPE project_nt AS TABLE OF project_type; CREATE TABLE emp ( empno NUMBER(5), ename VARCHAR2(30), projects project_nt );

INSERT INTO emp VALUES(1,'Ellison', projecttable ( project_type('Telephone Billing','System Analyst'), project_type('Housing Loans','Oracle DBA') )

CREATE TYPE Animal_ty AS OBJECT ( Breed VARCHAR2(50), Name VARCHAR2(25), BirthDate date ); CREATE TYPE Animal_nt AS TABLE OF Animal_ty ; CREATE TABLE Breeder( BreederName VARCHAR2(25), Animals Animal_nt );

 Transactioon  A set of SQL statements  Available TCL statements  COMMIT  ROLLBACK  SAVEPOINT

 COMMIT  ROLLBACK INSERT INTO emp (empno, ename, sal) VALUES(101,’Abid’,2300) COMMIT; DELETE FROM emp; ROLLBACK;

insert into tom1 values( '1' ); insert into tom1 values( '2' ); insert into tom1 values( '3' ); insert into tom1 values( ‘4' ); insert into tom1 values( ‘5' ); insert into tom1 values( ‘6' ); insert into tom1 values( ‘7' ); insert into tom1 values( ‘8' ); insert into tom1 values( ‘9' ); SAVEPOINT a; ROLLBACK; COMMIT; RESULT: 7,8,9 ROLLBACK to SAVEPOINT a; RESULT: 1,2,3,7,8,9 COMMIT; ROLLBACK; RESULT: 1,2,3,4,5,6,7,8,9