Constraints can be created at the same time as the table is created (using CREATE
TABLE) or after the table has been created (using ALTER TABLE)
Sequences:
•
Automatically generates unique numbers.
•
Is sharable object. (used by multiple users)
•
Is typically used to create a primary key value.
•
Save time to write application code to generate unique numbers.
•
Speeds up the efficiency of accessing sequence values when cached in memory.
Syntax:
CREATE SEQUENCE
sequence_name
[INCREMENT BY
n
]
[START WITH
n
]
[{MAXVALUE
n
| NOMAXVALUE
} ]
[{MINVALUE
n
| NOMINVALUE
} ]

[{CYCLE | NOCYCLE
} ]
[{CACHE
n
| NOCACHE} ]
•
Sequence name follows the same rule as the Table Name or Constraint Name (start with a
letter, max length 30 characters).
•
If INCREMENT BY is omitted, default is 1, negative n means decreasing.
•
If START WITH is omitted, default is 1.
•
MAXVALE/MINVALUE specifies the maximum/minimum value of the sequence. The
default is NO for both.
•
By default, no CYCLE. Oracle cache 20 values.
Alter Sequence
ALTER SEQUENCE
sequence_name
[INCREMENT BY
n
]
[{MAXVALUE
n
| NOMAXVALUE} ]
[{MINVALUE
n
| NOMINVALUE} ]
[{CYCLE | NOCYCLE} ]
[{CACHE
n
| NOCACHE} ]


You've reached the end of your free preview.
Want to read all 5 pages?
- Fall '14
- Foreign key, Constraint, data integrity