Re: [PERFORM] OT - select + must have from - sql standard syntax?

2006-06-14 Thread Antoine

 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.

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


Re: [PERFORM] OT - select + must have from - sql standard syntax?

2006-06-14 Thread Dave Dutcher
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] 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


---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


[PERFORM] OT - select + must have from - sql standard syntax?

2006-06-13 Thread Antoine

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.

---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [PERFORM] OT - select + must have from - sql standard syntax?

2006-06-13 Thread Jim C. Nasby
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  [EMAIL PROTECTED]
Pervasive Software  http://pervasive.comwork: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf   cell: 512-569-9461

---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [PERFORM] OT - select + must have from - sql standard syntax?

2006-06-13 Thread Tom Lane
Jim C. Nasby [EMAIL PROTECTED] 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

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

   http://www.postgresql.org/docs/faq


Re: [PERFORM] OT - select + must have from - sql standard syntax?

2006-06-13 Thread Greg Stark

Tom Lane [EMAIL PROTECTED] 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


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