473,537 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

postgres metadata

Is there something in Postgres that corresponds to the rowid
pseudocolumn in Oracle, which represents the unique address of the row
of data in the table? If so, how would you access that in a query?
--
Barbara E. Lindsey,
COG RDC
Phone: (352) 392-5198 ext. 314 Fax: (352) 392-8162

----
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #1
8 8699

I think oid is what you want.

select oid,* from table;

Take Care,
James

On Wed, 26 Nov 2003, Barbara Lindsey wrote:
Is there something in Postgres that corresponds to the rowid
pseudocolumn in Oracle, which represents the unique address of the row
of data in the table? If so, how would you access that in a query?
--
Barbara E. Lindsey,
COG RDC
Phone: (352) 392-5198 ext. 314 Fax: (352) 392-8162

----
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


->->->->->->->->->->->->->->->->->->---<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<
James Thompson 138 Cardwell Hall Manhattan, Ks 66506 785-532-0561
Kansas State University Department of Mathematics
->->->->->->->->->->->->->->->->->->---<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #2
On Wed, 26 Nov 2003, James Thompson wrote:

I think oid is what you want.

select oid,* from table;

Not if the table is created without OID's. Which may become default
in 7.5.

--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: le*@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #3
so what do you have to do to create the table with oids?
I am using v7.4

Larry Rosenman wrote:
On Wed, 26 Nov 2003, James Thompson wrote:

I think oid is what you want.

select oid,* from table;


Not if the table is created without OID's. Which may become default
in 7.5.



--
Barbara E. Lindsey,
COG RDC
Phone: (352) 392-5198 ext. 314 Fax: (352) 392-8162

----
CONFIDENTIALITY NOTICE: The information contained in this electronic
message is legally privileged and confidential and intended only for the
use of the individual(s) or entity(ies) named above. If the reader of
this message is not the intended recipient, you are hereby notified that
any dissemination, distribution, or copying of this email or any of it's
components is strictly prohibited. If you have received this email in
error, please contact the sender.
----
---------------------------(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 12 '05 #4
On Wed, 26 Nov 2003, Barbara Lindsey wrote:
so what do you have to do to create the table with oids?
I am using v7.4 It's still default in 7.4. (to create with OID's).

You can optionally create a table WITHOUT OIDs in 7.3+.
Take Care,
James

On Wed, 26 Nov 2003, Barbara Lindsey wrote:
Is there something in Postgres that corresponds to the rowid
pseudocolumn in Oracle, which represents the unique address of the row
of data in the table? If so, how would you access that in a query?
--
Barbara E. Lindsey,
COG RDC
Phone: (352) 392-5198 ext. 314 Fax: (352) 392-8162

----
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


->->->->->->->->->->->->->->->->->->---<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<
James Thompson 138 Cardwell Hall Manhattan, Ks 66506 785-532-0561
Kansas State University Department of Mathematics
->->->->->->->->->->->->->->->->->->---<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Larry Rosenman wrote:
On Wed, 26 Nov 2003, James Thompson wrote:

I think oid is what you want.

select oid,* from table;


Not if the table is created without OID's. Which may become default
in 7.5.




--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: le*@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #5
On Wed, Nov 26, 2003 at 11:20:54AM -0500, Barbara Lindsey wrote:
Is there something in Postgres that corresponds to the rowid
pseudocolumn in Oracle, which represents the unique address of the row
of data in the table? If so, how would you access that in a query?


Maybe ctid? It's the physical column position, so it changes as soon as
the row is UPDATEd, or even during VACUUM.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"La espina, desde que nace, ya pincha" (Proverbio africano)

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #6
Please remember:

- OIDs are NOT unique
- CTIDs are unique but not constant
- SERIALs are unique and forever

On Wed, Nov 26, 2003 at 10:39:43AM -0600, James Thompson wrote:

I think oid is what you want.

select oid,* from table;

Take Care,
James

On Wed, 26 Nov 2003, Barbara Lindsey wrote:
Is there something in Postgres that corresponds to the rowid
pseudocolumn in Oracle, which represents the unique address of the row
of data in the table? If so, how would you access that in a query?
--
Barbara E. Lindsey,
COG RDC
Phone: (352) 392-5198 ext. 314 Fax: (352) 392-8162

----
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

->->->->->->->->->->->->->->->->->->---<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<
James Thompson 138 Cardwell Hall Manhattan, Ks 66506 785-532-0561
Kansas State University Department of Mathematics
->->->->->->->->->->->->->->->->->->---<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<



---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly


--
Martijn van Oosterhout <kl*****@svana.org> http://svana.org/kleptog/ "All that is needed for the forces of evil to triumph is for enough good
men to do nothing." - Edmond Burke
"The penalty good people pay for not being interested in politics is to be
governed by people worse than themselves." - Plato


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE/xS8ZY5Twig3Ge+YRAoKTAJ9yAXy29UTYJ3vlAgoEExvDoGMeBw Cgy9lO
DB8HOHV9HOYYA9fASRhYPvs=
=Y6ir
-----END PGP SIGNATURE-----

Nov 12 '05 #7

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Is there something in Postgres that corresponds to the rowid
pseudocolumn in Oracle, which represents the unique address of the
row of data in the table? If so, how would you access that
in a query?
...
so what do you have to do to create the table with oids?
I am using v7.4


The "hidden" column oid is created by default in all current versions
of PostgreSQL, including 7.4. In the future, the default may
change, and you would need to add the words "WITH OIDS" to
the end of your CREATE TABLE command.

While oids are not guaranteed to be unique, they may suit your needs.
The problem is that the oid column has no "unique" constraint, and
that the oids will eventually wrap. The number of oids the system
uses is very, very large, but finite, so keep in mind that it may
someday wraparound. You can always create your own unique constraint
on the oid column, but this is not recommended as inserts may fail.

Another system column, "ctid", is also automatically created, and
cannot be turned off. However, it is generally only guaranteed to
be the same for the life of the transaction. If you are doing a
subselect or something else within a single query, the ctid should
work fine.

Your best bet may be to create your own column, and put a unique
constraint on it. See the documentation on "SERIAL" for a good way
of doing this. When you add such a column, you may want to append
"WITHOUT OIDS" to the end of your CREATE TABLE command, as you will
not be using them (oids), and it will save you some space.

Finally, you can simulate a sequential row number by using a
temporary sequence. Keep in mind this is not a column of the
table at all, but merely a way of numbering the rows returned.
This number cannot be used to access the table in any way.

CREATE TEMPORARY SEQUENCE row_number;
SELECT nextval('row_number'), foo, bar, baz FROM mytable
WHERE foo>200 ORDER BY baz DESC;

Without knowing exactly what you are trying to do, it is hard to say
which approach would be best, but in general, use ctid if you can,
use a sequence (or the application) if you just need numbering,
use a SERIAL for everything else, and use oids for quick unimportant
queries.

- --
Greg Sabino Mullane gr**@turnstep.com
PGP Key: 0x14964AC8 200311262036
-----BEGIN PGP SIGNATURE-----

iD8DBQE/xVeVvJuQZxSWSsgRAgX5AKDbLqN65UEekaQbnwDRh1mFtLov/wCgsT8x
MpowtcfvoAYaycOti2DIQIM=
=h3jL
-----END PGP SIGNATURE-----

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #8
gr**@turnstep.com writes:
The problem is that the oid column has no "unique" constraint ...


unless you add one, viz:

create unique index mytable_oids on mytable (oid);

which is de rigueur for any table you intend to rely on OID as an
identifier for. The index is needed not only to ensure uniqueness
but as a mechanism for fast access to a particular row by OID.

You should be aware though that once the OID counter wraps around (every
4 billion OIDs) there is a small chance that a newly-created OID will
duplicate a prior entry, resulting in a "duplicate key" failure in a
transaction that really didn't do anything wrong. If you have a moral
aversion to writing retry loops in your client code then this will
disgust you. My own take on it is that there are enough reasons why you
will need retry loops that one more shouldn't bug you.

These comments generally apply to SERIAL and the other alternatives
Greg mentioned, as well. The only difference is how fast do the
identifiers get eaten and how far is it to the wraparound point ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #9

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

Similar topics

1
2775
by: Brett Selleck | last post by:
I would like to start collecting Metadata on my XML schemas. I have searched the web for a method of automatically extracting Metadata from an XSD file and have come up empty handed. Basically what I am looking for is a VB Script or J Script that parses an XSD file and outputs the metadata in a structured format. For examle: Given this simple...
1
8672
by: Santhu | last post by:
What is the difference between METADATA and MANIFEST and where do they get stored? Thank you
7
6636
by: Abdul-Wahid Paterson | last post by:
Hi, I have had a site working for the last 2 years and have had no problems until at the weekend I replace my database server with a newer one. The database migration went like a dream and I had the whole db changed over in 1 hour. Since the upgrade I have been getting the following error message sporadically.
3
8677
by: warwick.poole | last post by:
I am interested in finding out about Enterprise scale Postgres installations and clustering, especially on Linux. Essentially I would like to know the possibility that Postgres can store the database data in a central location (ex: on a SAN fiber array) and have a cluster of machines sharing processor/RAM/IO bandwidth to do the application...
16
8197
by: Michal Hlavac | last post by:
Hello, I am working on web portal. There are some ads. We have about 200 000 ads. Every ad have own directory called ID, where is 5 subdirectories with various sizes of 5 images. Filesystem is too slow. But I don't know, if I store these images into postgres, performace will grow. Second question is, what kind of hardware I need for...
18
5100
by: Joe Lester | last post by:
This thread was renamed. It used to be: "shared_buffers Question". The old thread kind of died out. I'm hoping to get some more direction by rephrasing the problem, along with some extra observations I've recently made. The core of the problem is that Postgres is filling up my hard drive with swap files at the rate of around 3 to 7 GB per...
2
8764
by: EP | last post by:
I'm looking for a method by which to access Windows files metadata and have not been able to find anything in the standard modules or via Google - what is the standard approach? Shamefully I really do not understand Windows file system - e.g. is properties metadata attached to the file? if I change that metadata do I change the file's...
1
3856
by: Jack Orenstein | last post by:
I'm trying to configure PHP 5.2.0 with support for Postgres 8.1.3. Postgres was installed with FC5 without source. PHP's configure needs source. When I run configure: configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path I tried downloading Postgres source and modifying PHPs configure to point to...
0
2687
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which I want to insert into the database. Funny is it works for files larger than 8000 Bytes. If a file is less than 1000 Bytes I get the following message: Error message: --invalid input syntax for...
0
7301
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7688
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7281
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7644
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3353
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3345
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.