-
Copyrights 2010 - Online Training Oracle Applications. All Rights Reserved.
|
Sequences Syntax Ex In the above example, name of the sequence is seq1. It generated numbers 1,2,3…..so on How can we use the sequence? I want to create a table student18, and insert 5 rows into it. student18
Observe, the column sno, the values are 1,2,3,4,5. Note Ex 1 In the above insert commands, we are not hard coding the values of the sno column. Note Select seq1.currval from dual; -- 5 So, when ever we want numbers to generated automatically, we use sequence. Like credit card numbers, mobile numbers, sim card numbers, bank account numbers etc; Lets look at few more examples Ex 2 We can restrict sequence to a maximum number by using maxvalue option. Ex 3 Create sequence seq3 After sequence reaching maxvalue, it again starts generating number 1,2, so on Query to see list of all the sequences Select sequence_name from user_sequences; If you do not want the sequence, we can drop it. Syntax Ex Imp There are two pseudo columns, related to sequences.
Nextval will generate the next number.
|