pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Cliff Crawford <cjc26@cornell.edu>
To: Robert Beer <Robert.Beer@Callserve.com>
Cc: 'pgsql-sql@postgresql.org' <pgsql-sql@postgresql.org>
Subject: Re: Newbie ex-Oracle person's question: Oracle ROWID = PSQL OID, Orac le ROWNUM = PSQL ???
Date: Fri, 11 May 2001 11:01:10 -0400
Message-ID: <20010511110110.B26098@cornell.edu> (raw)
In-Reply-To: <AAF7CC40BD87F347A2A8BD72F9D5514361EE3B@csoff2exc01.callserve.com>
References: <AAF7CC40BD87F347A2A8BD72F9D5514361EE3B@csoff2exc01.callserve.com>

* Robert Beer <Robert.Beer@Callserve.com> menulis:
> Oracle has a ROWNUM pseudo column that works like this ...
> TEST>select callid, rownum from cs_calls where rownum < 5;
> 
>     CALLID     ROWNUM
> ---------- ----------
>       7806          1
>       7807          2
>       7809          3
>       6443          4
> 
> 4 rows selected.
> 
> ... which can be quite handy.
> 
> Is there something like this in PSQL?

You can use the LIMIT clause:

SELECT callid FROM cs_calls LIMIT 4;

See
<http://postgresql.readysetnet.com/users-lounge/docs/7.1/postgres/sql-select.html;
for more info.


> By the way, having used Oracle since 1987 it's a pleasure to use PSQL.
> Someone actually thinks about the implemented features.
> For example, Oracle's implementation of ROWNUM gives them in the order the
> rows were BEFORE the ORDER BY, which is not of much use as adding an ORDER
> BY jumbles them up.  Duh!

LIMIT in PostgreSQL applies *after* ORDER BY, so you won't have this
problem :)


-- 
Cliff Crawford   http://www.sowrong.org/
birthday party cheesecake jellybean BOOM



view thread (3+ messages)  latest in thread

Message-ID: <20010511110110.B26098@cornell.edu>
Permalink:  ../20010511110110.B26098@cornell.edu/
Also on:    postgresql.org/message-id/20010511110110.B26098@cornell.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: cjc26@cornell.edu, Robert.Beer@Callserve.com
  Subject: Re: Newbie ex-Oracle person's question: Oracle ROWID = PSQL OID, Orac le ROWNUM = PSQL ???
  In-Reply-To: <20010511110110.B26098@cornell.edu>
  References: <AAF7CC40BD87F347A2A8BD72F9D5514361EE3B@csoff2exc01.callserve.com> <20010511110110.B26098@cornell.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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