Chapter 12 Additional Database Objects. Chapter Objectives  Define the purpose of a sequence and state how it can be used by an organization  Explain.

Slides:



Advertisements
Similar presentations
9 Creating and Managing Tables. Objectives After completing this lesson, you should be able to do the following: Describe the main database objects Create.
Advertisements

Data Definition Language (DDL)
Creating Tables. 2 home back first prev next last What Will I Learn? List and provide an example of each of the number, character, and date data types.
Chapter Thirteen Sequences Dr. Chitsaz Objectives: Sequence objects Create and use sequences Application of sequences.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
11-1 Copyright © Oracle Corporation, All rights reserved. Different type of keys.
Database Programming Sections 13. Marge Hohly  1. Which statements are True about the following sequence? The sequence was used to generate numbers.
10 Copyright © 2004, Oracle. All rights reserved. Creating Other Schema Objects.
Introduction to Structured Query Language (SQL)
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
Copyright س Oracle Corporation, All rights reserved. 13 Other Database Objects.
A Guide to MySQL 7. 2 Objectives Understand, define, and drop views Recognize the benefits of using views Use a view to update data Grant and revoke users’
Introduction to Structured Query Language (SQL)
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Introduction to Oracle9i: SQL1 Views. Introduction to Oracle9i: SQL2 Chapter Objectives Create a view, using CREATE VIEW command or the CREATE OR REPLACE.
Using SQL Queries to Insert, Update, Delete, and View Data © Abdou Illia MIS Spring 2015 Wednesday 1/28/2015 Chapter 3A.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
SQL's Data Definition Language (DDL) – View, Sequence, Index.
Chapter 6 Additional Database Objects
13 Other Database Objects Important Legal Notice:  Materials on this lecture are from a book titled “Oracle Education” by Kochhar, Gravina, and Nathan.
Objectives After completing this lesson, you should be able to do the following: Categorize the main database objects Review the table structure List.
Dr. Chen, Oracle Database System (Oracle) 1 Chapter 6 Additional Database Objects (up to p.195 and all in the pptx file) Jason C. H. Chen, Ph.D. Professor.
Copyright © 2004, Oracle. All rights reserved. Lecture 3: Creating Other Schema Objects Lecture 3: Creating Other Schema Objects ORACLE.
Oracle Database Administration
12 Copyright © Oracle Corporation, All rights reserved. Other Database Objects.
Other database objects (Sequence). What Is a Sequence? A sequence: Automatically generates sequential numbers Is a sharable object Is typically used to.
11 Copyright © 2007, Oracle. All rights reserved. Creating Other Schema Objects.
Set operators The set operaotrs combine the result of two or more component queries into one result. queries containing set operators are called compound.
Chapter 6 Additional Database Objects Oracle 10g: SQL.
Chapter 5 Sequences.
10 Copyright © 2009, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
1 Copyright © 2006, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
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.
Database Programming Sections 11 & 12 – Creating, and Managing Views, Sequences, Indexes, and Synonymns.
CHAPTER 9 Views, Synonyms, and Sequences. Views are used extensively in reporting applications and also to present subsets of data to applications. Synonyms.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Controlling User Access. 2 home back first prev next last What Will I Learn? Compare the difference between object privileges and system privileges Construct.
Database Programming Sections 11 & 12 –Sequences, Indexes, and Synonymns.
George Mpopo | Rosebank College ADVANCED DATABASES WITH ORACLE 11g FOR ADDB7311 LEARNING UNIT 2 of 7.
© 2009 Punjab University College of Information Technology (PUCIT) September 8, 2009 Slide 1 (SQL) Other Database Objects Asif Sohail University of the.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
SQL ACTION QUERIES AND TRANSACTION CONTROL CS 260 Database Systems.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
Session 1 Module 1: Introduction to Data Integrity
Chapter 4 Indexes. Indexes Logically represents subsets of data from one or more tables View Generates numeric valuesSequence Basic unit of storage; composed.
Transactions, Roles & Privileges Oracle and ANSI Standard SQL Lecture 11.
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
DDL and Views. Database Objects Logically represents subsets of data from one or more tables View Generates numeric valuesSequence Basic unit of storage;
Chapter 13Introduction to Oracle9i: SQL1 Chapter 13 User Creation and Management.
Database Programming Sections 12 – Sequences, Indexes, and Synonymns.
Chapter 12Introduction to Oracle9i: SQL1 Chapter 12 Additional Database Objects.
Chapter 3 Table Creation and Management Oracle 10g: SQL.
 CONACT UC:  Magnific training   
What is the Flashback Database? Improves a database’s availability Useful alternative to traditional restoration methods Contains Flashback logs Archived.
1 Chapters 19 and 20  Ch. 19: By What Authority? Users Roles Grant and revoke Synonyms  Ch. 20: Changing the Oracle Surroundings Indexes Clusters Sequences.
Other database objects (Sequence and view). What Is a Sequence? A sequence: Automatically generates sequential numbers Is a sharable object Is typically.
ITEC 313 Database Programming
Oracle Certified 1z0-047 Exam Questions
Creating Other Schema Objects
Other Database Objects
Creating Other Schema Objects
Chapter 5 Sequences.
Chapter 4 Indexes.
CH 4 Indexes.
CH 4 Indexes.
Contents Preface I Introduction Lesson Objectives I-2
IST 318 Database Administration
Other Database Objects
Presentation transcript:

Chapter 12 Additional Database Objects

Chapter Objectives  Define the purpose of a sequence and state how it can be used by an organization  Explain why gaps may appear in the integers generated by a sequence  Correctly use the CREATE SEQUENCE command to create a sequence  Define the purpose of a sequence and state how it can be used by an organization  Explain why gaps may appear in the integers generated by a sequence  Correctly use the CREATE SEQUENCE command to create a sequence

Chapter Objectives  Identify which options cannot be changed by the ALTER SEQUENCE command  Use NEXTVAL and CURRVAL in an INSERT command  Explain when Oracle9i will automatically create an index  Create an index, using the CREATE INDEX command  Identify which options cannot be changed by the ALTER SEQUENCE command  Use NEXTVAL and CURRVAL in an INSERT command  Explain when Oracle9i will automatically create an index  Create an index, using the CREATE INDEX command

Chapter Objectives  Delete an index, using the DELETE INDEX command  Create a PUBLIC synonym  Delete a PUBLIC synonym  Identify the contents of different versions of views used to access the data dictionary, based on the prefix of the view  Delete an index, using the DELETE INDEX command  Create a PUBLIC synonym  Delete a PUBLIC synonym  Identify the contents of different versions of views used to access the data dictionary, based on the prefix of the view

Database Objects  Anything that has a name and defined structure  Includes: –Sequence – generate sequential integers –Index – quickly locate specific records –Synonym – alias for other database objects  Anything that has a name and defined structure  Includes: –Sequence – generate sequential integers –Index – quickly locate specific records –Synonym – alias for other database objects

Sequences  Used for internal control purposes by providing sequential integers for auditing  Used to generate unique value for primary key column – no correlation with actual row contents  Used for internal control purposes by providing sequential integers for auditing  Used to generate unique value for primary key column – no correlation with actual row contents

CREATE SEQUENCE Command  Various intervals allowed – Default: 1  Can specify starting number – Default: 1  Various intervals allowed – Default: 1  Can specify starting number – Default: 1

CREATE SEQUENCE Command  Can specify MINVALUE for decreasing sequence, MAXVALUE for increasing  Numbers can be reused if CYCLE specified  ORDER clause for application cluster environment  Use CACHE to pre-generate integers – Default: 20  Can specify MINVALUE for decreasing sequence, MAXVALUE for increasing  Numbers can be reused if CYCLE specified  ORDER clause for application cluster environment  Use CACHE to pre-generate integers – Default: 20

CREATE SEQUENCE Command Example

Verifying Sequence Values Query USER_SEQUENCES data dictionary view

Using Sequence Values  NEXTVAL – generates integer  CURRVAL – contains last integer generated by NEXTVAL  NEXTVAL – generates integer  CURRVAL – contains last integer generated by NEXTVAL

Altering Sequence Definitions  Use ALTER SEQUENCE command  START WITH value cannot be altered – drop sequence and re-create  Changes cannot make current integers invalid  Use ALTER SEQUENCE command  START WITH value cannot be altered – drop sequence and re-create  Changes cannot make current integers invalid

ALTER SEQUENCE Command Example

DROP SEQUENCE Command Previous values generated are not affected by removing a sequence from a database

Indexes  Stores frequently referenced value and row ID (ROWID)  Can be based on one column, multiple columns, functions, or expressions  Stores frequently referenced value and row ID (ROWID)  Can be based on one column, multiple columns, functions, or expressions

Creating an Index  Implicitly created by PRIMARY KEY and UNIQUE constraints  Explicitly created by CREATE INDEX command  Implicitly created by PRIMARY KEY and UNIQUE constraints  Explicitly created by CREATE INDEX command

CREATE INDEX Command Example

Verifying an Index Indexes listed in USER_INDEXES view

Removing an Index Use DROP INDEX command

Synonyms  Serve as permanent aliases for database objects  Can be private or public –Private synonyms are only available to user who created them –PUBLIC synonyms are available to all database users  Serve as permanent aliases for database objects  Can be private or public –Private synonyms are only available to user who created them –PUBLIC synonyms are available to all database users

CREATE SYNONYM Command Syntax

CREATE SYNONYM Command Example

Deleting a SYNONYM  A private synonym can be deleted by owner  A PUBLIC synonym can only be deleted by a user with DBA privileges  A private synonym can be deleted by owner  A PUBLIC synonym can only be deleted by a user with DBA privileges

Data Dictionary  Stores information about database objects  Owned by user SYS  Cannot be directly accessed by users  Displays contents through data dictionary views  Stores information about database objects  Owned by user SYS  Cannot be directly accessed by users  Displays contents through data dictionary views

View Prefixes