0% found this document useful (0 votes)
47 views6 pages

Pseudocolumn and Sequences

1. A sequence is a schema object that automatically creates unique numbers. 2. It is a shareable object that replaces application code for generating id numbers. 3. The document provides examples of how to create a sequence, insert values into tables using the NextVal and CurrVal pseudocolumns of a sequence, and limitations defined when creating the sequence.

Uploaded by

Senthil Raj
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views6 pages

Pseudocolumn and Sequences

1. A sequence is a schema object that automatically creates unique numbers. 2. It is a shareable object that replaces application code for generating id numbers. 3. The document provides examples of how to create a sequence, insert values into tables using the NextVal and CurrVal pseudocolumns of a sequence, and limitations defined when creating the sequence.

Uploaded by

Senthil Raj
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

PSEUDOCOLUMN & SEQUENCE

SCHEMA OBJECT IT CREATES UNIQUE NUMBER SHAREABLE OBJECT IT REPLACE THE APPLICATION CODE

Document prepared by: AN.Murugappan

PSEUDO COLUMN SYSDATE SYSTIMESTAMP USER UID ROWNUM ROWID CURRVAL NEXTVAL [SYSDATE] SELECT SYSDATE FROM DUAL;

[SYSTIMESTAMP] SELECT SYSTIMESTAMP FROM DUAL;

[USER] SELECT USER FROM DUAL;

[UID] SELECT UID FROM DUAL;

[ROWNUM] SELECT ROWNUM, FIRST_NAME, SALARY FROM EMPLOYEES;

[ROWID] SELECT ROWID, FIRST_NAME, SALARY FROM EMPLOYEES;

SELECT ROWID, FIRST_NAME, SALARY FROM EMPLOYEES WHERE ROWID = 'AAAC9EAAEAAAABXAAD'

SEQUENCE
[CURRVAL, NEXTVAL]

1. SEQUENCE IS A SCHEMA OBJECT 2. IT AUTOMATICALLY CREATE A UNIQUE NUMBERS 3. IT IS A SHAREABLE OBJECT 4. IT REPLACES THE APPLICATION CODE

[HOW TO CREATE SEQUENCE]


CREATE SEQUENCE SEQ1 INCREMENT BY 1 START WITH 1 MAXVALUE 5;

create table cse ( roll_no number, Name varchar(20), department_name varchar(3)

);

create table eee ( roll_no number, name varchar(20), department_name varchar(3) );

select * from cse;

[HOW TO USE THE CREATED SEQUENCE]


[NEXTVAL]

insert into cse values(seq1.nextval,'Murugappan','cse');

insert into cse values(seq1.nextval,'Raja','cse');

insert into eee values(seq1.nextval,'senthil','eee');

[CURRTVAL]
select seq1.currval from dual; 3

select seq1.nextval from dual; 4 insert into cse values(seq1.nextval,'Karthi','cse');

insert into cse values(seq1.nextval,'jon','cse');

select * from cse;

select * from eee;

select seq1.currval from dual; 5 insert into eee values(seq1.nextval,'RAJA','eee');

BECAUSE THE MAXIMUM VALU IS 5 (MENTIONED AT THE TIME OF SEQUENCE CREATION)

You might also like