Lecture 06 S1 2023
Lecture 06 S1 2023
INF 312
DATABASE DESIGN AND
DEVELOPMENT
Semester 1, 2023
Week 6 – Lecture 6
READINGS
• Casteel, Chapter 6 of
Oracle 12c textbook
• This chapter is important
for SQL skill development.
19 March 2023 3
Lecture Objectives
After completing this chapter, you should be able to do the
following:
• Define the purpose of a sequence and explain how it
can be used in a database
• Use the CREATE SEQUENCE command to create a
sequence
• Call and use sequence values, and identify which
options can’t be changed by the ALTER SEQUENCE
command
• Delete a sequence
19 March 2023 4
Lecture 6 Objectives
After completing this chapter, you should be able to do the
following:
• Create indexes with the CREATE INDEX command
• Explain the main index structures: B-tree and bitmap
• Rename an index with the ALTER INDEX command
• Remove an index with the DELETE INDEX command
• Create and remove a public synonym
Database Objects
• An object is anything that has a name and defined
structure
Creating a Sequence
• Use the CREATE SEQUENCE command
• Various intervals are allowed – Default: 1
• You can specify the starting number – Default:
1
Removing a Sequence
• Use the DROP SEQUENCE command to
delete a sequence
• Previous sequence values are not affected
by removing a sequence from a database
Verifying an Index
Removing an Index
• Use the DROP INDEX command to remove
an index
Deleting a SYNONYM
• A private synonym can be deleted by its
owner
• A PUBLIC synonym can only be deleted by a
user with DBA privileges
SUMMARY
• A sequence is created with the CREATE SEQUENCE
command.
• The ALTER SEQUENCE command is used to modify an
existing sequence. The only settings that can’t be
modified are the START WITH option and any option
that would be invalid because of previously generated
values.
• The DROP SEQUENCE command deletes an existing
sequence.
• Oracle 11g creates an index for PRIMARY KEY and
UNIQUE constraints automatically.
• An explicit index is created with the CREATE INDEX
command.
33
SUMMARY
• An index can be dropped with the DROP INDEX
command.
• An index can be renamed with the ALTER INDEX
command.
• A synonym is created by using the CREATE SYNONYM
command.
• A synonym is deleted by using the DROP SYNONYM
command.
34
Syntax Guide
35
Syntax Guide
19 March 2023 36