Question

dual table

Asked by: bhombal

In oracle dual table is a table in the schema of SYS. with a column (dummy varchar2(1)). If the column length is 1 then how does it return a value whose length more than 1. What internal mecanism is used for dual table.
Please explain in detail.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2002-04-19 at 03:17:09ID20291330
Tags

dual

,

oracle

,

table

Topic

Oracle Database

Participating Experts
9
Points
30
Comments
14

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Inserting '&' in a table with column-type VARCHAR2.
    I have a table 'tmp' with a column 'name' whose column-type is VARCHAR2. I want to insert data 'Dun & Bradstreet' into this column. insert into tmp values('Dun & Bradstreet'). Then it takes it as comman-line argument requiring user-input. How do I avoid this and make...
  2. Problem with respect to the table "Dual"
    After creating a database schema, when I check the table dual, the record count is 2. When I use nextval it returns me 2 values instead of one. This is because of the record count being 2 in the table "dual". What is the cause for this? And how can it be rectified?
  3. DUAL TABLE
    1) when last I asked a question on this, i got some statements that if we create any table with X as single varchar2(1) column, we can use it exactly the same way as dual. 2) But when i tried, it did not work out that way. 3) Do we have to grant some roles/privileges to crea...
  4. Dual Table
    can anyone explain how dual table is created and if i want to construct the table similar to dual(with special functionalaties) how can i do this
  5. schema
    i need help with creating new user to have readonly access to two schemas.

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: kretzschmarPosted on 2002-04-19 at 03:25:58ID: 6953108

dual is a virtual table

 

by: p_yaroslavPosted on 2002-04-19 at 03:39:10ID: 6953143

Hi!

DUAL is a table automatically created by Oracle along with the data dictionary. DUAL is in the schema of the user SYS, but is accessible by the name DUAL to all users. It has one column, DUMMY, defined to be VARCHAR2(1), and contains one row with a value 'X'. Selecting from the DUAL table is useful for computing a constant expression with the SELECT statement. Because DUAL has only one row, the constant is returned only once. Alternatively, you can select a constant, pseudocolumn, or expression from any table, but the value will be returned as many times as there are rows in the table.


Columnt length doesn't affect on value you choose from table.
You can select from any your table any constant value.

For example:
--------
create table test( a varchar(1))
/

select sysdate from test;
select user from test
etc ....

--------


Best regards!
Yaroslav.

 

by: k_murli_krishnaPosted on 2002-04-19 at 04:05:35ID: 6953204

1) dual table is a sysnonym or double for all imagined tables.

2) Usually we select from dual to see the effect of functions or to use the value(s) selected for column(s) of other table(s).

3) Since data of any type can be used in quotes as varchar2 type and on concatination everything turns into a varchar2 type.

4) One value X represents that any imaginary table of any symmetry/dimensions can be expanded from this.

5) As kretzschmar says it is a imaginary table with a dummy column and value which can represent any number of real tables with any number of columns and rows.

desc dual;

Name     Null?    Type
-------- ------ -----------
DUMMY           VARCHAR2(1)

select * from dual;

D
-
X

6) We can insert, update, delete from dual and we can alter and drop dual. But all these are not recommended since it is part of data dictionary.

7) there will be no effect to it's functionality as long as it exists i.e. table dual in sys with dummy varchar2(1) as a minimum.

8) So it's functionality is to act as a virtual table and change shape like a chameleon so that select query's work against it as required.

All the best!

--- k_murli_krishna

 

by: k_murli_krishnaPosted on 2002-04-19 at 04:18:51ID: 6953236

Yaroslav, a comment would have been better. But I must accept that you are a bigger expert and have helped me once in a while.

--- k_murli_krishna

 

by: k_murli_krishnaPosted on 2002-04-19 at 04:19:34ID: 6953238

Yaroslav, a comment would have been better. But I must accept that you are a bigger expert and have helped me once in a while.

--- k_murli_krishna

 

by: DrSQLPosted on 2002-04-19 at 07:01:27ID: 6953692

bhombal,
   I'm not sure what more you're looking for.  DUAL is a table in SYS (as you noted) and there is a public synonym created when the database catalog is built.  It's no different from any other table - there's no magic or internal mechanism associated with it.

   If anyone is doubtful, try creating a table called FRED with a single column called BARNEY varchar2(1) and insert a single record into it "insert into fred value ('?');".  Then try any "DUAL" sql statement you have with FRED instead of DUAL.  You'll see it works the same.

   DUAL was created to have a standard name for solving a problem with relational/SQL implementations - the handling of a single value constant, or anything that didn't require processing against a table.  For example, SQL can calculate the equation "132.33/44+5", but unless there's a table you can select from, there's no records returned.  DUAL was created to be a single-row table (the column is never referenced and is unimportant) that would give you the record you need.

   One of the most maddening debugging problems for early Oracle programmers was finding out why they got results that were double or got multiple-rows returned or twice the result set.  The problem was that someone had done a full import and added a second record to the DUAL table.

   You should also note that some newer SQL implementations have solved this by not requiring a FROM clause when the value is a constant, or non-table based single value.

Good luck!

 

by: jtriftsPosted on 2002-04-19 at 07:14:18ID: 6953741

There isn't any fancy mechanism for it.

I could just as easily select SYSDATE from emp, customer, whatever. However is do SELECT SYSDATE from EMP, I will get one record of sysdate for each record in the table.

The importance is that there is ALWAYS one and only one record in the table.  

It's main purpose is to allow the selection of functions (such as SYSDATE, sequence_name.nextval, sequence_name.curval, etc.) without specifying a "real" table.  (Dual IS a real table, but I mean a non-dummy table).

If you used:

select sysdate
from customer
where rownum = 1; in one instance, and

select sysdate
from emp
where rownum = 1 in another instance,

you'd be getting SYSDATE for both (though at different times!)...but the usage might cause the casual observer to make incorrect assumptions about the nature of the data in either of these tables.

So don't go thinking that DUAL is some really clever structure that is capable of deriving dates, and complex functions...because all it really is is a dummy table.

But the use of DUAL indicates that these activities are taking place.  

...

but now that I look at the other experts comments (oops) I realise that I am simply restating what they've already said...

regards,
JT

 

by: asimkovskyPosted on 2002-04-19 at 08:52:35ID: 6954131

Actually, there is one common misconception about DUAL regarding its origin. It was not created as a convenient single-row table to generate derived, non-static data.  It was originally created as an internal-only table to build data dictionary views on.  The programmer (can't remember his name) was looking for a way to create twice the number of rows in a table by doing a simple join on DUAL.  The results were something similar to this:

SELECT *
FROM emp
UNION ALL
SELECT *
FROM emp;

This was way back in the very early versions of Oracle, so they were trying to find a way to do something simple when the functionlity to do it easier ways wasn't there yet.  It turned out to be a handy table, so they kept it and created a public synonym for it to open the use up to everybody.


Andrew

 

by: asimkovskyPosted on 2002-04-19 at 09:11:22ID: 6954183

Here's the excerpt from the February issue of Oracle Magazine (SENDMAIL section):

I created the DUAL table as an underlying object in the Oracle Data Dictionary. It was never meant to be seen itself, but instead used inside a view that was expected to be queried. The idea was that you could do a JOIN to the DUAL table and create two rows in the result for every one row in your table. Then, by using GROUP BY, the resulting join could be summarized to show the amount of storage for the DATA extent and for the INDEX extent(s). The name, DUAL, seemed apt for the process of creating a pair of rows from just one.
Chuck Weiss, Oracle



Andrew

 

by: jtriftsPosted on 2002-04-22 at 00:33:12ID: 6959139

Nice one Andrew!
Regards,
JT

PS Was it always in the SYS schema?  I was once told that one should not select from SYS.DUAL, rather select simply from DUAL.

I believe the reasoning was that there was a good chance that the DUAL table was going to be moved to another schema -- and since the synonym and grants would be suitably applied, using SYS.DUAL was dangerous.

Good point or load of malarkey?

 

by: DrSQLPosted on 2002-04-22 at 05:58:31ID: 6959657

JT,
<.02>
  Oracle has always warned against referencing SYS or SYSTEM objects specifically.  I never took it too seriously because I could always create one.  A more credible warning was that they might change the structure of the table, so we should never reference the column (DUMMY) or assume we knew the value of that one row.

  Also, in version 3 (when I started using Oracle), the recursive sql required by synonyms was considered wasteful (and on a 4Mhz VAX, you needed to be efficient).  It was generally accepted practice to create your own DUAL table (although DUMMY and ANSWER were more common names) so that you could be sure that it existed.  By version 5, this practice had fallen out of favor (DUAL had stayed and the duplicate-record problem I mentioned had bitten a lot of people).

</.02>

 

by: MindphaserPosted on 2002-06-07 at 11:44:00ID: 7063171

Please update and finalize this old, open question. Please:

1) Award points ... if you need Moderator assistance to split points, comment here with details please or advise us in Community Support with a zero point question and this question link.
2) Ask us to delete it if it has no value to you or others
3) Ask for a refund so that we can move it to our PAQ at zero points if it did not help you but may help others.

EXPERT INPUT WITH CLOSING RECOMMENDATIONS IS APPRECIATED IF ASKER DOES NOT RESPOND.

Thanks,

** Mindphaser - Community Support Moderator **

 

by: anand_2000vPosted on 2003-08-22 at 06:53:08ID: 9203299


No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
points to be given to asimkovsky
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

anand_2000v
EE Cleanup Volunteer

 

by: new_attitudePosted on 2004-06-14 at 01:40:06ID: 11304423

Ok I have read all on this that I could find and I think I get it - with just one question:

i understand it is a way to solve a problem or figure out the best way to lay out a query for dates, mathematical or functions that return a single value.  However, I am somewhat confused and can't seem to come up with an example of utilizing it for a join.  I apologize for my ignorant question - I understand very clearly that it is a single row single column table with one value and completely undederstand for testing out a query but would love some samples of utilizing for a join and then group by (slightly confused about the way it assists for returning useful data in conjunction with another table)

Thank you in advance for your patience.

Susan

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...