pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedSequences...
19+ messages / 14 participants
[nested] [flat]
* Sequences...
@ 1998-07-27 20:34 James Olin Oden <joden@lee.k12.nc.us>
0 siblings, 1 reply; 19+ messages in thread
From: James Olin Oden @ 1998-07-27 20:34 UTC (permalink / raw)
To: pgsql-sql
I had a asked this question earlier and did not get a response, so here
it is again.
When implementing an "autoincrementing" field in several tables, is
common practice to create sequence for each table, or is it OK to use
just one sequence? I know right off the bat that if there was a
requirement that there be no holes in the key for a particualr table
that one sequence over multiple tables (like in check register) would
not do, but if this requirment is not there, would having one sequnence
for all (provided your projected number of total records in all the
tables is less than 4 billion) tables be OK?
Thanks...james
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: [SQL] Sequences...
@ 1998-07-29 09:30 Peter T Mount <peter@retep.org.uk>
parent: James Olin Oden <joden@lee.k12.nc.us>
0 siblings, 0 replies; 19+ messages in thread
From: Peter T Mount @ 1998-07-29 09:30 UTC (permalink / raw)
To: James Olin Oden <joden@Lee.k12.nc.us>; +Cc: pgsql-sql
On Mon, 27 Jul 1998, James Olin Oden wrote:
>
> I had a asked this question earlier and did not get a response, so here
> it is again.
>
> When implementing an "autoincrementing" field in several tables, is
> common practice to create sequence for each table, or is it OK to use
> just one sequence? I know right off the bat that if there was a
> requirement that there be no holes in the key for a particualr table
> that one sequence over multiple tables (like in check register) would
> not do, but if this requirment is not there, would having one sequnence
> for all (provided your projected number of total records in all the
> tables is less than 4 billion) tables be OK?
I don't see any problem there.
--
Peter T Mount peter@retep.org.uk or petermount@earthling.net
Main Homepage: http://www.retep.org.uk
PostgreSQL JDBC Faq: http://www.retep.org.uk/postgres
^ permalink raw reply [nested|flat] 19+ messages in thread
* Sequences
@ 2002-02-11 13:43 Hunter, Ray <rhunter@enterasys.com>
0 siblings, 3 replies; 19+ messages in thread
From: Hunter, Ray @ 2002-02-11 13:43 UTC (permalink / raw)
To: pgsql-sql
I have various sequences in my database set up for ids. My question is:
How can I get the current value of the sequence without creating a session
and using the currval function?
I would like to take the current value of the sequence and use it for a
value in an insert statement.
Example:
insert into users ( "user_id", "user_fname", "user_lname",
"user_email" )
values ( 'current sequence', 'Ray', 'Hunter',
'rhunter@enterasys.com' );
Thanks,
Ray Hunter
Firmware Engineer
ENTERASYS NETWORKS
Phone: 801 887-9888
Fax: 801 972-5789
Email: rhunter@enterasys.com <mailto:rhunter@enterasys.com>
www: www.enterasys.com <http://www.enterasys.com;
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: Sequences
@ 2002-02-11 14:22 Markus Bertheau <twanger@bluetwanger.de>
parent: Hunter, Ray <rhunter@enterasys.com>
2 siblings, 0 replies; 19+ messages in thread
From: Markus Bertheau @ 2002-02-11 14:22 UTC (permalink / raw)
To: Hunter, Ray <rhunter@enterasys.com>; +Cc: pgsql-sql
On Mon, 2002-02-11 at 14:43, Hunter, Ray wrote:
> I have various sequences in my database set up for ids. My question is:
> How can I get the current value of the sequence without creating a session
> and using the currval function?
>
> I would like to take the current value of the sequence and use it for a
> value in an insert statement.
>
>
> Example:
>
> insert into users ( "user_id", "user_fname", "user_lname",
> "user_email" )
> values ( 'current sequence', 'Ray', 'Hunter',
> 'rhunter@enterasys.com' );
>
You probably wouldn't want to use the current but the next value of the
sequence. Common solution is to set the default for the column user_id
to something like
nextval(users_user_id_seq"::text)
and omit user_id in the insert statement such that the default value is
taken.
Markus Bertheau
Cenes Data GmbH
Attachments:
signature.asc (application/pgp-signature, 231B) download
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: Sequences
@ 2002-02-11 14:36 Bruno Wolff III <bruno@wolff.to>
parent: Hunter, Ray <rhunter@enterasys.com>
2 siblings, 0 replies; 19+ messages in thread
From: Bruno Wolff III @ 2002-02-11 14:36 UTC (permalink / raw)
To: Hunter, Ray <rhunter@enterasys.com>; +Cc: pgsql-sql
On Mon, Feb 11, 2002 at 08:43:23AM -0500,
"Hunter, Ray" <rhunter@enterasys.com> wrote:
> I have various sequences in my database set up for ids. My question is:
> How can I get the current value of the sequence without creating a session
> and using the currval function?
>
> I would like to take the current value of the sequence and use it for a
> value in an insert statement.
>
>
> Example:
>
> insert into users ( "user_id", "user_fname", "user_lname",
> "user_email" )
> values ( 'current sequence', 'Ray', 'Hunter',
> 'rhunter@enterasys.com' );
I think you want to use nextval in this context. currval is used when you
have already gotten a new sequence number and want to use it in several
inserts in the same transaction.
If you make user_id a serial type, then its default value will be nextval
and you could use:
insert into users ( "user_fname", "user_lname", "user_email" )
values ('Ray', 'Hunter', 'rhunter@enterasys.com' );
to add a row.
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: Sequences
@ 2002-02-11 15:12 Hunter, Ray <rhunter@enterasys.com>
0 siblings, 3 replies; 19+ messages in thread
From: Hunter, Ray @ 2002-02-11 15:12 UTC (permalink / raw)
To: 'Bruno Wolff III' <bruno@wolff.to>; +Cc: pgsql-sql
The only problem with this solution is that I have already incremented the
sequence and need to use the current value? Is there a way to assign the
value to a variable and then use it in an insert statement?
This is just a hashed out example. I am hoping it can all be done in sql
statements...
Example:
var num = select last_value from user_table_id_seq;
insert into users ( "user_id", "user_fname", "user_lname",
"user_email" )
values ( 'num', 'Ray', 'Hunter', 'rhunter@enterasys.com' );
If I could do this is would be great...Is it possible?
Thanks,
Ray Hunter
Firmware Engineer
ENTERASYS NETWORKS
-----Original Message-----
From: Bruno Wolff III [mailto:bruno@wolff.to]
Sent: Monday, February 11, 2002 7:37 AM
To: Hunter, Ray
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Sequences
On Mon, Feb 11, 2002 at 08:43:23AM -0500,
"Hunter, Ray" <rhunter@enterasys.com> wrote:
> I have various sequences in my database set up for ids. My question
> is: How can I get the current value of the sequence without creating a
> session and using the currval function?
>
> I would like to take the current value of the sequence and use it for
> a value in an insert statement.
>
>
> Example:
>
> insert into users ( "user_id", "user_fname", "user_lname",
> "user_email" )
> values ( 'current sequence', 'Ray', 'Hunter',
'rhunter@enterasys.com'
> );
I think you want to use nextval in this context. currval is used when you
have already gotten a new sequence number and want to use it in several
inserts in the same transaction.
If you make user_id a serial type, then its default value will be nextval
and you could use: insert into users ( "user_fname", "user_lname",
"user_email" )
values ('Ray', 'Hunter', 'rhunter@enterasys.com' );
to add a row.
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: Sequences
@ 2002-02-11 15:19 mallah@trade-india.com
parent: Hunter, Ray <rhunter@enterasys.com>
2 siblings, 0 replies; 19+ messages in thread
From: mallah@trade-india.com @ 2002-02-11 15:19 UTC (permalink / raw)
To: Hunter, Ray <rhunter@enterasys.com>; +Cc: pgsql-sql
Further to Brunos' suggestion,
if you require to use the same id for insertion in other tables
(slaves) you should
assign the value to a variable and use that value for inserting
in other referencing tables eg
$id = $dbh -> selectrow_array("select nextval('seq_name')"); (# perl
specific)
insert into users ( "user_id", "user_fname", "user_lname", "user_email"
)
values ( $id , 'Ray', 'Hunter', 'rhunter@enterasys.com' );
insert into user_details ( "user_id", ..... other details .... )
values ( $id , .... other details .... );
"Hunter, Ray" wrote:
>
>
> I have various sequences in my database set up for ids. My question
> is: How can I get the current value of the sequence without creating
> a session and using the currval function?
>
> I would like to take the current value of the sequence and use it for
> a value in an insert statement.
>
> Example:
>
> insert into users ( "user_id", "user_fname", "user_lname",
> "user_email" )
> values ( 'current sequence', 'Ray', 'Hunter',
> 'rhunter@enterasys.com' );
>
> Thanks,
>
> Ray Hunter
> Firmware Engineer
>
> ENTERASYS NETWORKS
>
> Phone: 801 887-9888
> Fax: 801 972-5789
> Email: rhunter@enterasys.com
> www: www.enterasys.com
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: Sequences
@ 2002-02-11 15:38 mallah@trade-india.com
parent: Hunter, Ray <rhunter@enterasys.com>
2 siblings, 0 replies; 19+ messages in thread
From: mallah@trade-india.com @ 2002-02-11 15:38 UTC (permalink / raw)
To: Hunter, Ray <rhunter@enterasys.com>; +Cc: pgsql-sql
hi hunter,
nextval increments the sequence in an atomic operation and returns the
current value
of the sequence. It is transaction safe in the sense,
if two webserver process do two transactions simultaneously they would
still get different
current vals.
so last_val should not be the approach.
forgive me if i am not understanding the intricacies of your
problem.
"Hunter, Ray" wrote:
>
>
> The only problem with this solution is that I have already incremented
> the sequence and need to use the current value? Is there a way to
> assign the value to a variable and then use it in an insert statement?
>
> This is just a hashed out example. I am hoping it can all be done in
> sql statements...
> Example:
> var num = select last_value from user_table_id_seq;
>
> insert into users ( "user_id", "user_fname", "user_lname",
> "user_email" )
> values ( 'num', 'Ray', 'Hunter', 'rhunter@enterasys.com' );
>
> If I could do this is would be great...Is it possible?
>
> Thanks,
>
>
>
> Ray Hunter
> Firmware Engineer
>
> ENTERASYS NETWORKS
>
> -----Original Message-----
> From: Bruno Wolff III [mailto:bruno@wolff.to]
> Sent: Monday, February 11, 2002 7:37 AM
> To: Hunter, Ray
> Cc: pgsql-sql@postgresql.org
> Subject: Re: [SQL] Sequences
>
> On Mon, Feb 11, 2002 at 08:43:23AM -0500,
> "Hunter, Ray" <rhunter@enterasys.com> wrote:
> > I have various sequences in my database set up for ids. My question
>
> > is: How can I get the current value of the sequence without creating
> a
> > session and using the currval function?
> >
> > I would like to take the current value of the sequence and use it
> for
> > a value in an insert statement.
> >
> >
> > Example:
> >
> > insert into users ( "user_id", "user_fname", "user_lname",
> > "user_email" )
> > values ( 'current sequence', 'Ray', 'Hunter',
> 'rhunter@enterasys.com'
> > );
>
> I think you want to use nextval in this context. currval is used when
> you have already gotten a new sequence number and want to use it in
> several inserts in the same transaction.
>
> If you make user_id a serial type, then its default value will be
> nextval and you could use: insert into users ( "user_fname",
> "user_lname", "user_email" )
>
> values ('Ray', 'Hunter', 'rhunter@enterasys.com' );
> to add a row.
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: Sequences
@ 2002-02-11 15:51 Bruno Wolff III <bruno@wolff.to>
parent: Hunter, Ray <rhunter@enterasys.com>
2 siblings, 0 replies; 19+ messages in thread
From: Bruno Wolff III @ 2002-02-11 15:51 UTC (permalink / raw)
To: Hunter, Ray <rhunter@enterasys.com>; +Cc: pgsql-sql
On Mon, Feb 11, 2002 at 10:12:33AM -0500,
"Hunter, Ray" <rhunter@enterasys.com> wrote:
> The only problem with this solution is that I have already incremented the
> sequence and need to use the current value? Is there a way to assign the
> value to a variable and then use it in an insert statement?
You should be doing this in one transaction in which case currval should
work. If you aren't doing it in one transaction, then your application
will need to remember the current value.
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: Sequences
@ 2002-02-11 17:25 Chris Ruprecht <chrup999@yahoo.com>
parent: Hunter, Ray <rhunter@enterasys.com>
2 siblings, 0 replies; 19+ messages in thread
From: Chris Ruprecht @ 2002-02-11 17:25 UTC (permalink / raw)
To: Hunter, Ray <rhunter@enterasys.com>; +Cc: 'Bruno Wolff III' <bruno@wolff.to>; pgsql-sql
<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 }
--></style><title>Re: [SQL] Sequences</title></head><body>
<div>Ray,</div>
<div><br></div>
<div>You can certainly store the value in a variable, how to do that
depends on the language you're using. If you're running PL/pgSQL, then
you would have to define the variable somewhere on top and then
use</div>
<div><x-tab> </x-tab></div>
<div>var_num := ...</div>
<div><br></div>
<div>Best regards,</div>
<div>Chris</div>
<div><br></div>
<div>At 10:12 -0500 02/11/2002, Hunter, Ray wrote:</div>
<blockquote type="cite" cite><font size="-1">The only problem with
this solution is that I have already incremented the sequence and need
to use the current value? Is there a way to assign the value to
a variable and then use it in an insert statement?</font><br>
</blockquote>
<blockquote type="cite" cite><font size="-1">This is just a hashed out
example. I am hoping it can all be done in sql
statements...</font><br>
<font size="-1">Example:</font><br>
<font size="-1"> var num =
select last_value from user_table_id_seq;</font><br>
</blockquote>
<blockquote type="cite"
cite> <font size="-1"> insert
into users ( "user_id", "user_fname",
"user_lname", "user_email" )</font><br>
<font size="-1"> values (
'num', 'Ray', 'Hunter', 'rhunter@enterasys.com' );</font><br>
</blockquote>
<blockquote type="cite" cite><br></blockquote>
<blockquote type="cite" cite><font size="-1">If I could do this is
would be great...Is it possible?</font><br>
</blockquote>
<blockquote type="cite" cite><br></blockquote>
<blockquote type="cite" cite><font size="-1">Thanks,</font><br>
</blockquote>
<blockquote type="cite" cite> <br>
</blockquote>
<blockquote type="cite" cite><font size="-1">Ray Hunter</font><br>
<font size="-1">Firmware Engineer</font><br>
</blockquote>
<blockquote type="cite" cite><font size="-1">ENTERASYS
NETWORKS</font><br>
</blockquote>
<blockquote type="cite" cite><br></blockquote>
<blockquote type="cite" cite><font size="-1">-----Original
Message-----</font><br>
<font size="-1">From: Bruno Wolff III [</font><a
href="mailto:bruno@wolff.to"><font
size="-1">mailto:bruno@wolff.to</font></a><font size="-1">]</font><br>
<font size="-1">Sent: Monday, February 11, 2002 7:37 AM</font><br>
<font size="-1">To: Hunter, Ray</font><br>
<font size="-1">Cc: pgsql-sql@postgresql.org</font><br>
<font size="-1">Subject: Re: [SQL] Sequences</font><br>
</blockquote>
<blockquote type="cite" cite><br></blockquote>
<blockquote type="cite" cite><font size="-1">On Mon, Feb 11, 2002 at
08:43:23AM -0500,</font><br>
<font size="-1"> "Hunter, Ray"
<rhunter@enterasys.com> wrote:</font><br>
<font size="-1">> I have various sequences in my database set up
for ids. My question</font><br>
<font size="-1">> is: How can I get the current value of the
sequence without creating a</font><br>
<font size="-1">> session and using the currval
function?</font><br>
<font size="-1">></font><br>
<font size="-1">> I would like to take the current value of the
sequence and use it for</font><br>
<font size="-1">> a value in an insert statement.</font><br>
<font size="-1">></font><br>
<font size="-1">></font><br>
<font size="-1">> Example:</font><br>
<font size="-1">></font><br>
<font size="-1">> insert into
users ( "user_id", "user_fname",
"user_lname",</font><br>
<font size="-1">> "user_email" )</font><br>
<font size="-1">> values (
'current sequence', 'Ray', 'Hunter',
'rhunter@enterasys.com'</font><br>
<font size="-1">> );</font><br>
</blockquote>
<blockquote type="cite" cite><font size="-1">I think you want to use
nextval in this context. currval is used when you have already gotten
a new sequence number and want to use it in several inserts in the
same transaction.</font><br>
</blockquote>
<blockquote type="cite" cite><font size="-1">If you make user_id a
serial type, then its default value will be nextval and you could use:
insert into users ( "user_fname", "user_lname",
"user_email" )</font><br>
</blockquote>
<blockquote type="cite" cite><font size="-1"> values ('Ray',
'Hunter', 'rhunter@enterasys.com' );</font><br>
<font size="-1">to add a row.</font></blockquote>
<div><br></div>
<div><br></div>
<x-sigsep><pre>--
</pre></x-sigsep>
<div align="center"><font color="#0000FF">Chris Ruprecht</font></div>
<div align="center"><font color="#0000FF">Network grunt and bit pusher
extraordinaíre</font></div>
</body>
</html>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
^ permalink raw reply [nested|flat] 19+ messages in thread
* SEQUENCES
@ 2006-10-02 16:39 Rodrigo Sakai <rodrigo.sakai@zanthus.com.br>
0 siblings, 3 replies; 19+ messages in thread
From: Rodrigo Sakai @ 2006-10-02 16:39 UTC (permalink / raw)
To: pgsql-sql
Hi all,
I need to get all sequences and their respective current values! Is there
any catalog table or any other away to get this???
Thanks in advance.
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: SEQUENCES
@ 2006-10-02 16:49 Andrew Sullivan <ajs@crankycanuck.ca>
parent: Rodrigo Sakai <rodrigo.sakai@zanthus.com.br>
2 siblings, 0 replies; 19+ messages in thread
From: Andrew Sullivan @ 2006-10-02 16:49 UTC (permalink / raw)
To: pgsql-sql
On Mon, Oct 02, 2006 at 01:39:38PM -0300, Rodrigo Sakai wrote:
>
> I need to get all sequences and their respective current values! Is there
> any catalog table or any other away to get this???
Here's a quick way to do it in a shell script, although it'd be sort
of inefficient:
for name in `psql -c "select relname from pg_class where relkind =
'S'" dbname; do psql -c "select last_value from $name" dbname; done.
A
--
Andrew Sullivan | ajs@crankycanuck.ca
Unfortunately reformatting the Internet is a little more painful
than reformatting your hard drive when it gets out of whack.
--Scott Morris
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: SEQUENCES
@ 2006-10-02 16:51 Thomas Kellerer <spam_eater@gmx.net>
parent: Rodrigo Sakai <rodrigo.sakai@zanthus.com.br>
2 siblings, 0 replies; 19+ messages in thread
From: Thomas Kellerer @ 2006-10-02 16:51 UTC (permalink / raw)
To: pgsql-sql
Rodrigo Sakai wrote on 02.10.2006 18:39:
> Hi all,
>
>
>
> I need to get all sequences and their respective current values! Is there
> any catalog table or any other away to get this???
>
>
Quote from the manual at:
http://www.postgresql.org/docs/8.1/static/catalog-pg-class.html
"The catalog pg_class catalogs tables and most everything else that has columns
or is otherwise similar to a table. This includes indexes (but see also
pg_index), sequences, views, composite types"
Thomas
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: SEQUENCES
@ 2006-10-03 14:59 Bruno Wolff III <bruno@wolff.to>
parent: Rodrigo Sakai <rodrigo.sakai@zanthus.com.br>
2 siblings, 0 replies; 19+ messages in thread
From: Bruno Wolff III @ 2006-10-03 14:59 UTC (permalink / raw)
To: Rodrigo Sakai <rodrigo.sakai@zanthus.com.br>; +Cc: pgsql-sql
On Mon, Oct 02, 2006 at 13:39:38 -0300,
Rodrigo Sakai <rodrigo.sakai@zanthus.com.br> wrote:
> Hi all,
>
>
>
> I need to get all sequences and their respective current values! Is there
> any catalog table or any other away to get this???
You can get their names from pg_class (with relkind = 'S') and then iterate
over the names and look at the table underlying each table (at last_value).
^ permalink raw reply [nested|flat] 19+ messages in thread
* Sequences
@ 2009-07-03 12:50 Andre Rothe <arothe@phosco.info>
0 siblings, 1 reply; 19+ messages in thread
From: Andre Rothe @ 2009-07-03 12:50 UTC (permalink / raw)
To: pgsql-sql
Hi!
Where are stored the sequence information? How I can query the
properties of a sequence like increment, max/min value, cache?
I'm looking for a table like user_sequences in Oracle, where I
can query all of my sequences.
Thanks
Andre
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: Sequences
@ 2009-07-03 21:35 Chris Browne <cbbrowne@acm.org>
parent: Andre Rothe <arothe@phosco.info>
0 siblings, 2 replies; 19+ messages in thread
From: Chris Browne @ 2009-07-03 21:35 UTC (permalink / raw)
To: pgsql-sql
Andre Rothe <arothe@phosco.info> writes:
> Where are stored the sequence information? How I can query the
> properties of a sequence like increment, max/min value, cache?
> I'm looking for a table like user_sequences in Oracle, where I
> can query all of my sequences.
cbbrowne=# create sequence foo;
CREATE SEQUENCE
cbbrowne=# select * from foo;
sequence_name | last_value | increment_by | max_value | min_value | cache_value | log_cnt | is_cycled | is_called
---------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
foo | 1 | 1 | 9223372036854775807 | 1 | 1 | 1 | f | f
(1 row)
Each sequence is effectively a relation.
--
output = ("cbbrowne" "@" "cbbrowne.com")
http://www3.sympatico.ca/cbbrowne/wp.html
Where do you want to Tell Microsoft To Go Today?
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: Sequences
@ 2009-07-04 12:35 Jasmin Dizdarevic <jasmin.dizdarevic@gmail.com>
parent: Chris Browne <cbbrowne@acm.org>
1 sibling, 1 reply; 19+ messages in thread
From: Jasmin Dizdarevic @ 2009-07-04 12:35 UTC (permalink / raw)
To: pgsql-sql
Nice Information. Does somebody know how to get the complete
create-statement of an existing table/view?
2009/7/3 Chris Browne <cbbrowne@acm.org>
> Andre Rothe <arothe@phosco.info> writes:
> > Where are stored the sequence information? How I can query the
> > properties of a sequence like increment, max/min value, cache?
> > I'm looking for a table like user_sequences in Oracle, where I
> > can query all of my sequences.
>
> cbbrowne=# create sequence foo;
> CREATE SEQUENCE
> cbbrowne=# select * from foo;
> sequence_name | last_value | increment_by | max_value |
> min_value | cache_value | log_cnt | is_cycled | is_called
>
> ---------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
> foo | 1 | 1 | 9223372036854775807 |
> 1 | 1 | 1 | f | f
> (1 row)
>
> Each sequence is effectively a relation.
> --
> output = ("cbbrowne" "@" "cbbrowne.com")
> http://www3.sympatico.ca/cbbrowne/wp.html
> Where do you want to Tell Microsoft To Go Today?
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
--
Mit freundlichen Grüßen
Dizdarevic Jasmin
Sonnenbergstr. 3
6714 Nüziders, AUT
jasmin.dizdarevic@gmail.com
+43 664 411 79 29
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: Sequences
@ 2009-07-04 17:26 Scott Marlowe <scott.marlowe@gmail.com>
parent: Jasmin Dizdarevic <jasmin.dizdarevic@gmail.com>
0 siblings, 0 replies; 19+ messages in thread
From: Scott Marlowe @ 2009-07-04 17:26 UTC (permalink / raw)
To: Jasmin Dizdarevic <jasmin.dizdarevic@gmail.com>; +Cc: pgsql-sql
Easiest way is with pg_dump -s -t tablename dbname
On Sat, Jul 4, 2009 at 6:35 AM, Jasmin
Dizdarevic<jasmin.dizdarevic@gmail.com> wrote:
> Nice Information. Does somebody know how to get the complete
> create-statement of an existing table/view?
>
> 2009/7/3 Chris Browne <cbbrowne@acm.org>
>>
>> Andre Rothe <arothe@phosco.info> writes:
>> > Where are stored the sequence information? How I can query the
>> > properties of a sequence like increment, max/min value, cache?
>> > I'm looking for a table like user_sequences in Oracle, where I
>> > can query all of my sequences.
>>
>> cbbrowne=# create sequence foo;
>> CREATE SEQUENCE
>> cbbrowne=# select * from foo;
>> sequence_name | last_value | increment_by | max_value |
>> min_value | cache_value | log_cnt | is_cycled | is_called
>>
>> ---------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
>> foo | 1 | 1 | 9223372036854775807 |
>> 1 | 1 | 1 | f | f
>> (1 row)
>>
>> Each sequence is effectively a relation.
>> --
>> output = ("cbbrowne" "@" "cbbrowne.com")
>> http://www3.sympatico.ca/cbbrowne/wp.html
>> Where do you want to Tell Microsoft To Go Today?
>>
>> --
>> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-sql
>
>
>
> --
> Mit freundlichen Grüßen
>
> Dizdarevic Jasmin
> Sonnenbergstr. 3
> 6714 Nüziders, AUT
>
> jasmin.dizdarevic@gmail.com
> +43 664 411 79 29
>
>
--
When fascism comes to America, it will be intolerance sold as diversity.
^ permalink raw reply [nested|flat] 19+ messages in thread
* Re: Sequences
@ 2009-07-04 20:50 Andre Rothe <arothe@phosco.info>
parent: Chris Browne <cbbrowne@acm.org>
1 sibling, 0 replies; 19+ messages in thread
From: Andre Rothe @ 2009-07-04 20:50 UTC (permalink / raw)
To: pgsql-sql
Thanks, I have used
SELECT sequence_name FROM information_schema.sequences WHERE
sequence_catalog=? AND sequence_schema=?
and then I can use
select * from <sequence-name>
It seems to work :-)
Andre
Chris Browne wrote:
> Andre Rothe <arothe@phosco.info> writes:
>> Where are stored the sequence information? How I can query the
>> properties of a sequence like increment, max/min value, cache?
>> I'm looking for a table like user_sequences in Oracle, where I
>> can query all of my sequences.
>
> cbbrowne=# create sequence foo;
> CREATE SEQUENCE
> cbbrowne=# select * from foo;
> sequence_name | last_value | increment_by | max_value | min_value | cache_value | log_cnt | is_cycled | is_called
> ---------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
> foo | 1 | 1 | 9223372036854775807 | 1 | 1 | 1 | f | f
> (1 row)
>
> Each sequence is effectively a relation.
^ permalink raw reply [nested|flat] 19+ messages in thread
end of thread, other threads:[~2009-07-04 20:50 UTC | newest]
Thread overview: 19+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-07-27 20:34 Sequences... James Olin Oden <joden@lee.k12.nc.us>
1998-07-29 09:30 ` Peter T Mount <peter@retep.org.uk>
2002-02-11 13:43 Sequences Hunter, Ray <rhunter@enterasys.com>
2002-02-11 14:22 ` Re: Sequences Markus Bertheau <twanger@bluetwanger.de>
2002-02-11 14:36 ` Re: Sequences Bruno Wolff III <bruno@wolff.to>
2002-02-11 15:19 ` Re: Sequences mallah@trade-india.com
2002-02-11 15:12 Re: Sequences Hunter, Ray <rhunter@enterasys.com>
2002-02-11 15:38 ` Re: Sequences mallah@trade-india.com
2002-02-11 15:51 ` Re: Sequences Bruno Wolff III <bruno@wolff.to>
2002-02-11 17:25 ` Re: Sequences Chris Ruprecht <chrup999@yahoo.com>
2006-10-02 16:39 SEQUENCES Rodrigo Sakai <rodrigo.sakai@zanthus.com.br>
2006-10-02 16:49 ` Re: SEQUENCES Andrew Sullivan <ajs@crankycanuck.ca>
2006-10-02 16:51 ` Re: SEQUENCES Thomas Kellerer <spam_eater@gmx.net>
2006-10-03 14:59 ` Re: SEQUENCES Bruno Wolff III <bruno@wolff.to>
2009-07-03 12:50 Sequences Andre Rothe <arothe@phosco.info>
2009-07-03 21:35 ` Re: Sequences Chris Browne <cbbrowne@acm.org>
2009-07-04 12:35 ` Re: Sequences Jasmin Dizdarevic <jasmin.dizdarevic@gmail.com>
2009-07-04 17:26 ` Re: Sequences Scott Marlowe <scott.marlowe@gmail.com>
2009-07-04 20:50 ` Re: Sequences Andre Rothe <arothe@phosco.info>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox