File: create_sequence.l.html

package info (click to toggle)
mpsql 2.0-2
  • links: PTS
  • area: non-free
  • in suites: slink
  • size: 2,912 kB
  • ctags: 5,665
  • sloc: ansic: 34,322; makefile: 3,525; sh: 17
file content (96 lines) | stat: -rw-r--r-- 3,657 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!-- manual page source format generated by PolyglotMan v3.0.4, -->
<!-- available via anonymous ftp from ftp.cs.berkeley.edu:/ucb/people/phelps/tcltk/rman.tar.Z -->

<HTML>
<HEAD>
<TITLE>"CREATE(SEQUENCE") manual page</TITLE>
</HEAD>
<BODY>
<A HREF="sql.html">SQL Reference Contents</A>
 
<H2><A NAME="sect0" HREF="#toc0">NAME </A></H2>
create sequence - create a new sequence number generator  
<H2><A NAME="sect1" HREF="#toc1">SYNOPSIS 
</A></H2>
<B>create sequence </B> seqname  <BR>
 <tt> </tt><tt> </tt>[<B>increment </B> incby_value]  <BR>
 <tt> </tt><tt> </tt>[<B>minvalue </B> min_value] 
 <BR>
 <tt> </tt><tt> </tt>[<B>maxvalue </B> max_value]  <BR>
 <tt> </tt><tt> </tt>[<B>start </B> start_value]  <BR>
 <tt> </tt><tt> </tt>[<B>cache </B> cache_value] 
 <BR>
 <tt> </tt><tt> </tt>[<B>cycle </B>]  <BR>
  
<H2><A NAME="sect2" HREF="#toc2">DESCRIPTION </A></H2>
<B>Create sequence</B> will enter a new sequence number 
generator into the current data base. Actually, new single block <B>table</B> 
with name  <I>seqname</I> will be created and initialized.  The generator will 
be `owned' by the user issuing the command. <P>
The  <B>increment</B> is optional clause. 
Positive value will make ascending sequence, negative - descending. Default 
value is 1.  <P>
The optional integer <B>minvalue</B> determines the minimum value 
a sequence can be. Defaults are 1/-2147483647 for ascending/descending sequences. 
<P>
Use optional integer <B>maxvalue</B> to determine the maximum value for sequence. 
Defaults are 2147483647/-1 for ascending/descending sequences. <P>
The optinal 
<B>start</B> value enables sequence to begin anywhere.  Default is  <B>minvalue</B> for 
ascending sequences and  <B>maxvalue</B> for descending ones. <P>
The <B>cache</B> option 
enables sequence numbers to be preallocated and  stored in memory for 
faster access. The minimum value is 1  (i.e. - no cache) and it is default. 
<B>NOTE:</B> each backend uses own cache to store allocated numbers. Cached but 
not used in current session numbers will be lost. <P>
The optional <B>cycle</B> keyword 
may be used to enable sequence to continue when the  <B>maxvalue/minvalue</B> 
has been reached by ascending/descending sequence. If the limit is reached, 
the next number generated will be  whatever the  <B>minvalue/maxvalue</B> is. 
<P>
After sequence created, You may use function <B>nextval</B> with sequence name 
as argument to get new number from sequence specified. Function <B>currval</B> 
('sequence_name') may be used to determine number returned by last call 
to <B>nextval</B> for specified sequence in current session. <P>
Use query like <BR>
 <P>
 
select * from &lt;sequence_name&gt;; <BR>
 <P>
 to get parameters of a sequence. <BR>
 <P>
Low-level 
locking is used to enable multiple simultaneous calls to a generator. <P>
 

<H2><A NAME="sect3" HREF="#toc3">EXAMPLES </A></H2>
-- <BR>
 -- Create sequence seq caching 2 numbers, starting with 10 <BR>
 -- 
<BR>
 create sequence seq cache 2 start 10; <BR>
 -- <BR>
 -- Select next number from sequence 
<BR>
 -- <BR>
 select nextval ('seq'); <BR>
 -- <BR>
 -- Use sequence in insert <BR>
 -- <BR>
 insert into table 
_table_ values (nextval ('seq'),...); <BR>
  
<H2><A NAME="sect4" HREF="#toc4">SEE ALSO </A></H2>
drop <A HREF="sequence.l.html">sequence(l)</A>
. <P>

<HR><P>
<A NAME="toc"><B>Table of Contents</B></A><P>
<UL>
<LI><A NAME="toc0" HREF="#sect0">NAME</A></LI>
<LI><A NAME="toc1" HREF="#sect1">SYNOPSIS</A></LI>
<LI><A NAME="toc2" HREF="#sect2">DESCRIPTION</A></LI>
<LI><A NAME="toc3" HREF="#sect3">EXAMPLES</A></LI>
<LI><A NAME="toc4" HREF="#sect4">SEE ALSO</A></LI>
</UL>
</BODY></HTML>