时间:2021-07-01 10:21:17 帮助过:17人阅读
CREATE SEQUENCE sequence [INCREMENT BY n] --每次增长的数值 [START WITH n] --从哪个值开始 [{MAXVALUE n | NOMAXVALUE}] [{MINVALUE n | NOMINVALUE}] [{CYCLE | NOCYCLE}] --是否需要循环 [{CACHE n | NOCACHE}]; --是否缓存登录
CREATE SEQUENCE dept_deptid_seq
INCREMENT BY 1
START WITH 1
MAXVALUE 9999
NOCACHE
NOCYCLE
INSERT INTO departments(department_id, department_name, location_id) VALUES (dept_deptid_seq.NEXTVAL, ‘Support‘, 2500);
CURRVAL 应在 NEXTVAL之后指定 ,否则会报CURRVAL 尚未在此会话中定义的错误。
SELECT sequence_name, min_value, max_value, increment_by, last_number FROM user_sequences;
1、将序列值装入内存可提高访问效率
2、序列在下列情况下出现裂缝:
3、如果不将序列的值装入内存(NOCACHE), 可使用表 USER_SEQUENCES 查看序列当前的有效值
ALTER SEQUENCE dept_deptid_seq INCREMENT BY 20 MAXVALUE 999999 NOCACHE NOCYCLE;
⑥、修改序列的注意事项
DROP SEQUENCE dept_deptid_seq; Sequence dropped.
在一个或多个列上创建索引
CREATE INDEX index ON table (column[, column]...);
在表 EMPLOYEES的列 LAST_NAME 上创建索引
CREATE INDEX emp_last_name_idx ON employees(last_name); Index created.
可以使用数据字典视图 USER_INDEXES 和 USER_IND_COLUMNS 查看索引的信息
SELECT ic.index_name, ic.column_name, ic.column_position col_pos,ix.uniqueness FROM user_indexes ix, user_ind_columns ic WHERE ic.index_name = ix.index_name AND ic.table_name = ‘EMPLOYEES‘;
CREATE SYNONYM e FOR employees; select * from e;
CREATE SYNONYM d_sum FOR dept_sum_vu; Synonym Created.
DROP SYNONYM d_sum; Synonym dropped.
Oracle——序列、索引、同义词
标签:values 字典 creat 错误 重建 oracl use acl 指定