- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
It is ITIL, that is how it is supposed to be! Look in the docs ;)
Admin
It's clearly a performance optimisation. Using a RDBMS just adds layers of bloat. hard coding the values is better.
Admin
And do everytime a distinct... and distinct.... and distinct...
Admin
"You can, for example, do SELECT 2 + 2, you must do SELECT 2 + 2 FROM dual."
I don't understand this sentence. To me it's not CAPTCHA validus.
Admin
My guess at the reason for this would be that the production system is so locked down that the bureaucracy to allow a new table to be created was more trouble than hacking this together -- a view, though, that's just a query!
I've created similar constructs in standalone queries in situations where flexible lookups were required for which the rate of change of the data exceeded the rate at which change management processes could respond.
Admin
“dual” is a fictional table
No; "dual" is a real table and, prior to Oracle 10g, caused real logical IO to happen. "select * from dual" if you're really bored.
Admin
Yeah. Agreed. I'm ITIL V3 certified; throwing ITIL at incompetence just leads to more complex but well-documented - in theory, at least - incompetence.
Admin
So, this is technically something that can only be accomplished in Oracle?
TRWTF is calling your company as your main product. OracleDB would have been much better.
Admin
Admin
i came across an oracle db once that had an additional record inserted into dual. that was a treat to debug.
Admin
The real wtf here is that nobody posted SELECT "frist" FROM dual!
Admin
some genius gave him access to create views but not tables, only thing that makes sense.
Admin
I think this is done for performance reasons. I mean less tables, means less data and speeds up queries and such
Admin
Security-wise, so you can't DELETE FROM it. Also just GRANT CREATE VIEW is enough, not RESOURCES.
Admin
I actually did this all the time when I had to create insert scripts.
insert into TABLE ( COLUMN1, ... ) select COLUMN1, ... from ( select null COLUMN1, ... from DUAL where 1=0 union select value1, ... from dual union select value2, ... from dual union etc. )
Never seen it in prod code though.
Admin
According to Wikipedia: 1982: RSI (Relational Software Inc.) renames itself Oracle Systems Corporation in order to align itself more closely with its primary product.
Admin
Admin
Indeed, the table dual is dual to the empty table. In other words, it is the top of the Dedekind-Maclane completion of the lattice of relations defined by the schema.
Admin
hungarian postfix?
int SomeCountStoredOffN;
Admin
error: ASSERT failed. Value 69834345 not = to 4.
no errors:
Admin
It's even more simple in MySQL because there you can do a SELECT without a FROM.
Admin
MSSQL, too
Admin
I'm pretty sure the primary goal was to circumvent user database access right. User can't create table he will create temporary. User can't create temporary he will try view... and so on
Never underestimate creativity of users who have time.
Admin
It could be a way of seeing changes in service lookups in the commits and diffs. It means the magic numbers / strings your app needs to reference are at least somewhere in the codebase, and refreshing some views is (only slightly) more stable than resetting all the lookup tables to their creation & initial population scripts. I see two WTFs here: 1/ No good way (in any DB platform) to keep lookup / config tables continuously synched with version controlled code 2/ dual
Admin
No, that is simply a rare island of sanity in an ocean of cunts.
Admin
"The Oracle database doesn't allow..."
Which Oracle database?
Try, "The Oracle DBMS doesn't allow..."
Admin
The real WTF is that this query is using union.
Enterprisey code requires this to be achieved by ref cursor and pipelined functions.
Captcha: haero - I came here to save this code from unenterprisiness
Admin
The most sensible reason for this code to exist is purely for the Remy joke in the comments. The tough part was getting Back to the Future written, financed, produced, and distributed to set up the cultural reference.
Admin
Am I the only one who noticed the Event Horizon reference?
Admin
Agreed. Dual is real table owned by system.
Admin
One thing you learn after many years in the business: don't ask why.
Admin
Now we just need Mike ... or really anyone to complain when there aren't 40 trolls for every legitimate post. (as if that would EVER happen).
eViL ... you have become my haero (captcha) with that post
Admin
The text is wrong. They meant to say "You canNOT, for example, do SELECT 2 + 2, you must do SELECT 2 + 2 FROM dual."
Admin
Fixed?
Admin
Nope. DUAL is owned by SYS.
Admin
Admin
ORA-00903: invalid table name
Admin
You are the wiiiiiind beneath my wiiiiiings!
Admin
There are many times that I wish that Oracle would allow this syntax! Unfortunately it doesn't.
Admin
"it just needs to work"
Admin
I've used the SELECT / UNION ALL motif a number of times in DB2, because it's the quickest/easiest way to do a load into a small table. I've even used it in ad hoc queries where I needed a handful of static rows to join against something else. I think both can be justified by their ad hoc nature.
It just never occurred to me to build a view based on such a SELECT, so there is no need for a real table at all.
Possibly because, while I'm a little weird, I don't think I'm actually insane...
Admin
Umm, why? Why not just
Admin
If you're generating the data from, say, a spreadsheet, it's easy to script it into this form. Then you can run the select to see what will be inserted. When that checks out, you insert it all at once instead of executing N insert statements...
Also, mine doesn't generate an ORA-00933: SQL command not properly ended.
Admin
Admin
No, that's ORA-22275.
Admin
Admin
It just contains a single row and a single column, value 1, iirc.
Tom Kyte's responses to people asking if they can change it to something else are quite amusing, mostly coming down to "Why would you want do that you fucking idiot?". Come to think of it that's his response to a lot of questions.
Admin
The owner of dual is SYS, but dual can be accessed by every user.
"dual" is a table that always exists in an Oracle database. It consists of exactly one column whose name is dummy and one record. The value of that record is X.
"Yes, it will (can) return an 'X', but as i'm trying to show in the examples, you can select just abount anything you want...
I didn't say it was a dummy table; it contains a column called "dummy""
http://en.allexperts.com/q/Oracle-1451/Dual.htm
Admin
Admin