1) When I submit the query below, it takes time, and then I get an end of communication error. Can you tell me
why it happens?
select a.empno,b.empno from (select rownum arow, empno from emp) a full outer join (select rownum brow, empno from emp) b on a.arow = b.brow;2) And also for the below query, I am getting a cartesian product, and I want to know why it happens.
select a.empno,b.empno from (select '1' arow, empno from emp) a full outer join (select '1' brow, empno from emp) b on a.arow = b.brow;
1) The dreaded ORA-3113 errors are never easy to track down. This means that your network connection to the database is being severed. I'm assuming that you are able to duplicate the the problem no matter when you issue the above query. If this is the case, then there is something going on in your session which is terminating your database connection. You'll have to turn client tracing on in your SQLNET.ORA file and send the trace files to Oracle Support for review.
2) You are not getting a "cartesian product", but a full outer join. This is exactly what you asked for. But you specified that the 'arow' and 'brow' columns contains the exact same number, the number '1', for EVERY ROW in each subquery! So every row from 'a' matches every row from 'b'.
Since every row in each subquery matches, the result set of your full outer join will be no different than a cartesian product, which matches every row in 'a' to every row in 'b'. In essence, you have forced a cartesian product.
For More Information
- Dozens more answers to tough Oracle questions from Brian Peasland are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Dig deeper on Oracle database design and architecture
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.