Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 12Introduction to Oracle9i: SQL1 Chapter 12 Additional Database Objects.

Similar presentations


Presentation on theme: "Chapter 12Introduction to Oracle9i: SQL1 Chapter 12 Additional Database Objects."— Presentation transcript:

1 Chapter 12Introduction to Oracle9i: SQL1 Chapter 12 Additional Database Objects

2 Chapter 12Introduction to Oracle9i: SQL2 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

3 Chapter 12Introduction to Oracle9i: SQL3 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

4 Chapter 12Introduction to Oracle9i: SQL4 CREATE SEQUENCE Command Various intervals allowed – Default: 1 Can specify starting number – Default: 1

5 Chapter 12Introduction to Oracle9i: SQL5 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

6 Chapter 12Introduction to Oracle9i: SQL6 CREATE SEQUENCE Command Example

7 Chapter 12Introduction to Oracle9i: SQL7 Verifying Sequence Values Query USER_SEQUENCES data dictionary view

8 Chapter 12Introduction to Oracle9i: SQL8 Using Sequence Values NEXTVAL – generates integer CURRVAL – contains last integer generated by NEXTVAL

9 Chapter 12Introduction to Oracle9i: SQL9 Altering Sequence Definitions Use ALTER SEQUENCE command START WITH value cannot be altered – drop sequence and re-create Changes cannot make current integers invalid

10 Chapter 12Introduction to Oracle9i: SQL10 ALTER SEQUENCE Command Example

11 Chapter 12Introduction to Oracle9i: SQL11 DROP SEQUENCE Command Previous values generated are not affected by removing a sequence from a database

12 Chapter 12Introduction to Oracle9i: SQL12 Indexes Stores frequently referenced value and row ID (ROWID) Can be based on one column, multiple columns, functions, or expressions

13 Chapter 12Introduction to Oracle9i: SQL13 Creating an Index Implicitly created by PRIMARY KEY and UNIQUE constraints Explicitly created by CREATE INDEX command

14 Chapter 12Introduction to Oracle9i: SQL14 CREATE INDEX Command Example

15 Chapter 12Introduction to Oracle9i: SQL15 Verifying an Index Indexes listed in USER_INDEXES view

16 Chapter 12Introduction to Oracle9i: SQL16 Removing an Index Use DROP INDEX command

17 Chapter 12Introduction to Oracle9i: SQL17 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

18 Chapter 12Introduction to Oracle9i: SQL18 CREATE SYNONYM Command Syntax

19 Chapter 12Introduction to Oracle9i: SQL19 CREATE SYNONYM Command Example

20 Chapter 12Introduction to Oracle9i: SQL20 Deleting a SYNONYM A private synonym can be deleted by owner A PUBLIC synonym can only be deleted by a user with DBA privileges

21 Chapter 12Introduction to Oracle9i: SQL21 Data Dictionary Stores information about database objects Owned by user SYS Cannot be directly accessed by users Displays contents through data dictionary views

22 Chapter 12Introduction to Oracle9i: SQL22 View Prefixes


Download ppt "Chapter 12Introduction to Oracle9i: SQL1 Chapter 12 Additional Database Objects."

Similar presentations


Ads by Google