Professional Documents
Culture Documents
Object Description
A sequence:
• Automatically generates unique numbers
• Is a sharable object
• Is typically used to create a primary key value
• Replaces application code
• Speeds up the efficiency of accessing sequence
values when cached in memory
CREATE
CREATE SEQUENCE
SEQUENCE sequence
sequence
[INCREMENT
[INCREMENT BYBY n]
n]
[START
[START WITH
WITH n]
n]
[{MAXVALUE
[{MAXVALUE nn || NOMAXVALUE}]
NOMAXVALUE}]
[{MINVALUE
[{MINVALUE nn || NOMINVALUE}]
NOMINVALUE}]
[{CYCLE
[{CYCLE || NOCYCLE}]
NOCYCLE}]
[{CACHE
[{CACHE nn || NOCACHE}];
NOCACHE}];
SELECT
SELECT sequence_name,
sequence_name, min_value,
min_value, max_value,
max_value,
increment_by,
increment_by, last_number
last_number
FROM
FROM user_sequences;
user_sequences;
ALTER
ALTER SEQUENCE
SEQUENCE dept_deptid_seq
dept_deptid_seq
INCREMENT
INCREMENT BY
BY 20
20
MAXVALUE
MAXVALUE 999999
999999
NOCACHE
NOCACHE
NOCYCLE;
NOCYCLE;
Sequence
Sequence altered.
altered.
DROP
DROP SEQUENCE
SEQUENCE dept_deptid_seq;
dept_deptid_seq;
Sequence
Sequence dropped.
dropped.
An index:
• Is a schema object
• Is used by the Oracle server to speed up the
retrieval of rows by using a pointer
• Can reduce disk I/O by using a rapid path access
method to locate data quickly
• Is independent of the table it indexes
• Is used and maintained automatically by the
Oracle server
CREATE
CREATE INDEX
INDEX emp_last_name_idx
emp_last_name_idx
ON
ON employees(last_name);
employees(last_name);
Index
Index created.
created.
Index created.
SELECT *
FROM departments
WHERE UPPER(department_name) = 'SALES';
DROP
DROP INDEX
INDEX index;
index;
CREATE
CREATE [PUBLIC]
[PUBLIC] SYNONYM
SYNONYM synonym
synonym
FOR
FOR object;
object;
CREATE
CREATE SYNONYM
SYNONYM d_sum
d_sum
FOR
FOR dept_sum_vu;
dept_sum_vu;
Synonym
Synonym Created.
Created.
• Drop a synonym.
DROP
DROP SYNONYM
SYNONYM d_sum;
d_sum;
Synonym
Synonym dropped.
dropped.