- 1
- 0
- 约3.91万字
- 约 24页
- 2017-02-17 发布于湖北
- 举报
Confirming Sequences Once you have created your sequence, it is documented in the data dictionary. Since a sequence is a database object, you can identify it in the USER_OBJECTS data dictionary table. You can also confirm the settings of the sequence by selecting from the USER_SEQUENCES data dictionary view. Instructor Note Demo: 12_dd.sql Purpose: To illustrate the USER_SEQUENCES data dictionary view and its contents. Using a Sequence After you create your sequence, it generates sequential numbers for use in your tables. Reference the sequence values by using the NEXTVAL and CURRVAL pseudocolumns. NEXTVAL and CURRVAL Pseudocolumns The NEXTVAL pseudocolumn is used to extract successive sequence numbers from a specified sequence. You must qualify NEXTVAL with the sequence name. When you reference sequence.NEXTVAL, a new sequence number is generated and the current sequence number is placed in CURRVAL. The CURRVAL pseudocolumn is used to refer to a sequence number that the current user has just generated. NEXTVAL must be used to generate a sequence number in the current user’s session before CURRVAL can be referenced. You must qualify CURRVAL with the sequence name. When sequence.CURRVAL is referenced, the last value returned to that user’s process is displayed. Using a Sequence The example on the slide inserts a new department in the DEPARTMENTS table. It uses the DEPT_DEPTID_SEQ sequence for generating a new department number as follows: You can view the current value of the sequence: SELECT dept_deptid_seq.CURRVAL FROM dual; Suppose now you want to hire employees to staff the new department. The INSERT statement to be executed for all new employees can include the following code: INSERT INTO employees employee_id, department_id, ... VALUES employees_seq.NEXTVAL, dept_deptid_seq .CURRVAL, ... ; Note: The preceding example assumes that a sequence called EMPLOYEE_SEQ has already been created for generating new employee numbers. Caching Sequence Values Cache
您可能关注的文档
最近下载
- 市场部门市场营销专员工作手册(标准版).doc VIP
- 2025新课标义务教育数学(2022年版)课程标准试题库(含答案).docx VIP
- 电力工程专业设计工日定额-送电工程750kV部分.doc VIP
- 基于K-means和主成分分析的京张体育文化旅游带冰雪运动旅游市场研究.pdf VIP
- 电力工程设计收工日定额2012-3-28.doc VIP
- 人教版七年级下册英语全册教学设计(配2025年春新版教材).docx
- 电力工程专业设计工日定额-送电工程±500kV(直流)部分.doc VIP
- 2021春人教版九年级数学下册 第29章 全章教案.doc VIP
- 2025年湖北专升本武汉文理学院《动画概论》考试及答案.docx VIP
- 医院门诊服务优化与创新体系构建ppt课件.pptx
原创力文档

文档评论(0)