473,395 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Sequences


I'm hoping someone can tell me I'm wrong, but I'm thinking not. Anyway,
here it goes:

Sequence information is stored in their individual 1-row tables, with
an entry is pg_class of relkind 'S'. So you can't
really get a list of sequences with last_value in a single query
without a butt-ugly pile of UNIONs in a query
manufactured after a query on pg_class (i.e. SELECT * FROM seq1 UNION
SELECT * FROM seq2...). And
the result would have no schema name with the sequence name, unless I
make my UNION query that much butt-uglier
(i.e. SELECT schema1 || '.' || sequence_name,last_value FROM seq1 UNION
SELECT schema1 || '.' || sequence_name,
last_value FROM seq2,...).

Tell me I have an elegant solution there, and I'll give you flattery
points but I'll still laugh at you.

Anyone have any other tricks?

--------------------

Andrew Rawnsley
President
The Ravensfield Digital Resource Group, Ltd.
(740) 587-0114
www.ravensfield.com
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #1
1 1254
Andrew Rawnsley <ro**@ravensfield.com> writes:
Sequence information is stored in their individual 1-row tables, with
an entry is pg_class of relkind 'S'. So you can't
really get a list of sequences with last_value in a single query


Nope, you can't ... and I surely hope you weren't expecting that the
last_values would all be simultaneously valid ...

What I'd try for this is

select relname, get_last_value(relname) from pg_class where relkind = 'S';

where get_last_value() is a plpgsql function that does an EXECUTE.
But you must realize that there will be time skew between the
last_values.

What is the problem you really want to solve?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 11 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: temp | last post by:
Hi All, I wonder could someone help me with this? What I want to do is search through a list of letters and look for adjacent groups of letters that form sequences, not in the usual way of...
10
by: Vilson farias | last post by:
Greetings, I'm getting a big performance problem and I would like to ask you what would be the reason, but first I need to explain how it happens. Let's suppose I can't use sequences (it seams...
1
by: CSN | last post by:
I'm getting these errors when importing dumps: ERROR: relation "table1_id_seq" does not exist ERROR: relation "table2_id_seq" does not exist I renamed a couple tables, and the names of their...
4
by: Hemant Shah | last post by:
Folks, I have created bunch of sequences in DB2 7.2. How do I list all the defined sequences and if possible their current values? Thanks. --
1
by: J.Haan | last post by:
Hey all, does anyone know if it is in any way harmful to use a lot of sequences in a database? Does it have any disadvantages? I already noticed that sequences are hard to use with...
2
by: Peteris Krumins | last post by:
Hello, while reading through iso c standard (August 3, 1998), I noticed something I had never heard of in C: "Trigraph sequences", 5.2.1.1 The standard says: "All occurrences in a source file...
3
by: Ken | last post by:
HI: I'm reading a string that will be displayed in a MessageBox from a resource file. The string in the resource file contains escape sequences so they will be broken up into multiple lines. ...
18
by: Bruno Baguette | last post by:
Hello, I have to design a table wich will store some action reports. Each report have an ID like this 1/2004, 2/2004, ... and each years, they restart to 1 (1/2004, 1/2005, 1/2006,...). So, I...
5
by: Michael Fuhr | last post by:
I'd like to propose that certain GRANTs on a table cascade to the table's implicit sequences. In the current implementation (as of 7.4.5 and 8.0.0beta3), a table owner must typically issue GRANT...
4
by: JJ | last post by:
Is there a way of checking that a line with escape sequences in it, has no strings in it (apart from the escape sequences)? i.e. a line with \n\t\t\t\t\t\t\t\r\n would have no string in it a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.