pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
OT - select + must have from - sql standard syntax?
8+ messages / 5 participants
[nested] [flat]

* OT - select + must have from - sql standard syntax?
@ 2006-06-13 12:43  Antoine <melser.anton@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Antoine @ 2006-06-13 12:43 UTC (permalink / raw)
  To: pgsql-performance

Hi,
I don't have a copy of the standard on hand and a collegue is claiming
that there must be a from clause in a select query (he is an oracle
guy). This doesn't seem to be the case for postgres... does anyone
know?
Cheers
Antoine
ps. any one of them will do...
-- 
This is where I should put some witty comment.



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: OT - select + must have from - sql standard syntax?
@ 2006-06-13 21:02  Jim C. Nasby <jnasby@pervasive.com>
  parent: Antoine <melser.anton@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Jim C. Nasby @ 2006-06-13 21:02 UTC (permalink / raw)
  To: Antoine <melser.anton@gmail.com>; +Cc: pgsql-performance

On Tue, Jun 13, 2006 at 02:43:45PM +0200, Antoine wrote:
> Hi,
> I don't have a copy of the standard on hand and a collegue is claiming
> that there must be a from clause in a select query (he is an oracle
> guy). This doesn't seem to be the case for postgres... does anyone
> know?

Dunno, but I know that other databases (at least DB2) don't require FROM
either. In Oracle, if you want to do something like

SELECT now();

you actually have to do

SELECT now() FROM dual;

where dual is a special, hard-coded table in Oracle that has only one
row. Personally, I find their approach to be pretty stupid.
-- 
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: OT - select + must have from - sql standard syntax?
@ 2006-06-14 02:44  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Jim C. Nasby <jnasby@pervasive.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2006-06-14 02:44 UTC (permalink / raw)
  To: Jim C. Nasby <jnasby@pervasive.com>; +Cc: Antoine <melser.anton@gmail.com>; pgsql-performance

"Jim C. Nasby" <jnasby@pervasive.com> writes:
> On Tue, Jun 13, 2006 at 02:43:45PM +0200, Antoine wrote:
>> I don't have a copy of the standard on hand and a collegue is claiming
>> that there must be a from clause in a select query (he is an oracle
>> guy). This doesn't seem to be the case for postgres... does anyone
>> know?

> Dunno, but I know that other databases (at least DB2) don't require FROM
> either.

The spec does require a FROM clause in SELECT (at least as of SQL99, did
not check SQL2003).  However, it's clearly mighty useful to allow FROM
to be omitted for simple compute-this-scalar-result problems.  You
should respond to the Oracle guy that "SELECT whatever FROM dual" is not
in the standard either (certainly the spec does not mention any such
table).  And in any case an Oracle fanboy has got *no* leg to stand on
when griping about proprietary extensions to the spec.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: OT - select + must have from - sql standard syntax?
@ 2006-06-14 04:15  Greg Stark <gsstark@mit.edu>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 8+ messages in thread

From: Greg Stark @ 2006-06-14 04:15 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Jim C. Nasby <jnasby@pervasive.com>; Antoine <melser.anton@gmail.com>; pgsql-performance


Tom Lane <tgl@sss.pgh.pa.us> writes:

> The spec does require a FROM clause in SELECT (at least as of SQL99, did
> not check SQL2003).  However, it's clearly mighty useful to allow FROM
> to be omitted for simple compute-this-scalar-result problems.  You
> should respond to the Oracle guy that "SELECT whatever FROM dual" is not
> in the standard either (certainly the spec does not mention any such
> table).  

Well you could always create a "dual", it was always just a regular table. We
used to joke about what would happen to Oracle if you inserted an extra row in
it...

Oracle used to always require FROM, if it has stopped requiring it then that's
new. I had heard it had special-cased dual in later versions to avoid the
table access overhead, I suspect these two changes are related.

-- 
greg




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: OT - select + must have from - sql standard syntax?
@ 2006-06-14 06:36  Antoine <melser.anton@gmail.com>
  parent: Greg Stark <gsstark@mit.edu>
  1 sibling, 1 reply; 8+ messages in thread

From: Antoine @ 2006-06-14 06:36 UTC (permalink / raw)
  To: Greg Stark <gsstark@mit.edu>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Jim C. Nasby <jnasby@pervasive.com>; pgsql-performance

> > The spec does require a FROM clause in SELECT (at least as of SQL99, did
> > not check SQL2003).  However, it's clearly mighty useful to allow FROM
> > to be omitted for simple compute-this-scalar-result problems.  You
> > should respond to the Oracle guy that "SELECT whatever FROM dual" is not
> > in the standard either (certainly the spec does not mention any such
> > table).

Thanks for your answers guys. I was pretty sure DUAL wasn't in the
standard (never seen it outside an oracle context) but wasn't at all
sure about the FROM.
Cheers
Antoine
ps. shame the standard isn't "freely" consultable to save you guys
silly OT questions!


-- 
This is where I should put some witty comment.



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: OT - select + must have from - sql standard syntax?
@ 2006-06-14 13:58  Dave Dutcher <dave@tridecap.com>
  parent: Greg Stark <gsstark@mit.edu>
  1 sibling, 0 replies; 8+ messages in thread

From: Dave Dutcher @ 2006-06-14 13:58 UTC (permalink / raw)
  To: pgsql-performance

> -----Original Message-----
> From: pgsql-performance-owner@postgresql.org 
> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of 
> Greg Stark
> Sent: Tuesday, June 13, 2006 11:16 PM
> Subject: Re: [PERFORM] OT - select + must have from - sql 
> standard syntax?
[SNIP]
> 
> Well you could always create a "dual", it was always just a 
> regular table. We
> used to joke about what would happen to Oracle if you 
> inserted an extra row in
> it...


I've never used Oracle, so I don't understand why its called dual when
it only has one row?  Shouldn't it be called single?  :\


Dave




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: OT - select + must have from - sql standard syntax?
@ 2006-06-14 14:20  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Antoine <melser.anton@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2006-06-14 14:20 UTC (permalink / raw)
  To: Antoine <melser.anton@gmail.com>; +Cc: Greg Stark <gsstark@mit.edu>; Jim C. Nasby <jnasby@pervasive.com>; pgsql-performance

Antoine <melser.anton@gmail.com> writes:
> ps. shame the standard isn't "freely" consultable to save you guys
> silly OT questions!

You can get free "draft" versions that are close-enough-to-final to be
perfectly usable.  See our developers' FAQ for some links.  I like the
drafts partly because they're plain ASCII, and so far easier to search
than PDFs ...

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: OT - select + must have from - sql standard syntax?
@ 2006-06-14 19:04  Antoine <melser.anton@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 8+ messages in thread

From: Antoine @ 2006-06-14 19:04 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Greg Stark <gsstark@mit.edu>; Jim C. Nasby <jnasby@pervasive.com>; pgsql-performance

> You can get free "draft" versions that are close-enough-to-final to be
> perfectly usable.  See our developers' FAQ for some links.  I like the
> drafts partly because they're plain ASCII, and so far easier to search
> than PDFs ...

Great to know - thanks!
Cheers
Antoine

-- 
This is where I should put some witty comment.



^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2006-06-14 19:04 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-06-13 12:43 OT - select + must have from - sql standard syntax? Antoine <melser.anton@gmail.com>
2006-06-13 21:02 ` Jim C. Nasby <jnasby@pervasive.com>
2006-06-14 02:44   ` Tom Lane <tgl@sss.pgh.pa.us>
2006-06-14 04:15     ` Greg Stark <gsstark@mit.edu>
2006-06-14 06:36       ` Antoine <melser.anton@gmail.com>
2006-06-14 14:20         ` Tom Lane <tgl@sss.pgh.pa.us>
2006-06-14 19:04           ` Antoine <melser.anton@gmail.com>
2006-06-14 13:58       ` Dave Dutcher <dave@tridecap.com>

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