Doubt in DUAL TABLE

Hi,
below is one query
SQL> select * from dual;
D
XNow from the below Query I came to know that there is one field in the dual table DUMMY which is having VARCHAR2(1)
SQL> desc dual;
Name                                                  Null?    Type
DUMMY                                                          VARCHAR2(1)now my doubt is when I run the below query how it is displaying text more than 1 character
SQL> select 'how are you' from dual;
'HOWAREYOU'
how are youplease explain
thanks in advance.

Hi,
What you are SELECTing here nas no relation to any column in the table.
There's nothing special about the dual table regarding literals. Try
SELECT  'Hello'
FROM    scott.dept;Notice that scott.dept does not have any 5-character columns, yet a query on scott.dept is producing a 5-character column.
When you query a table, you don't have to SELECT all of the columns in the table. In fact, you don't have to SELECT any of the columns in the table, as you demonstrated.
The query you posted, like the query above, does not refer to any columns in its base table; it's not surprising that the output doesn't resemble any column in the base table. In the case of the query above, which is based on a table that has 3 columns, the one column that we are SELECTing can't have the characteristics of all 3 columns in the table. Which column do you think the output should resemble, and why? 'Hello' is the first column of output; does that mean it has to resemble the first column in the table, which happens to be defined as NUMBER (2)? 'Hello' is also the last column of output; does that mean it has to resemble the last column of the table? 'Hello' is directly in the center of the output; does that mean it has to resemble the column that happens to be in the middle of the table? Of course not!
Once agian, it is perfectly legal, and sometimes extremely useful, to have columns in a result set that have no connection at all to any column in the table.

Similar Messages

  • How to return number range from sql (dual table)

    in sql plus
    I need to display values (numbers)1 to 52 from dual
    eg,
    1
    2
    3
    4
    5
    etc...
    Is this possible, can you display a range of numbers from an sql statment without creating atble holding the required numbers.
    I am trying to display 1 to 52 (week numbers) but I need to do this from the dual table.
    Creating a table with values 1 to 52 looks like a waste?
    Thanks in anticipation.
    SD.

    If you're running on 9i you may find the solution I posted Re: List all days of a month in single SQL to be useful. Otherwise the general discussion will provide some illumination.
    Cheers, APC

  • Select multiple rows from dual table

    Is it possible to select multiple rows from dual table using a single select statement.
    i.e., i want the out put to be
    column_name
    1
    2
    3
    4
    Edited by: vidya.ramachandra on Dec 14, 2009 8:24 AM

    Aside from the fact you're responding to an old thread...
    1002424 wrote:
    While using CONNECT BY, I see it always leave behind one row.
    Suppose I have a condition based on which I have to generate constant rows like
    SELECT 1 FROM DUAL WHERE ROWNUM < N;
    Here if N = 0, still it gives out single row.... you are obviously doing something wrong in your code elsewhere, because that SQL statement does not always return a single row...
    SQL> SELECT 1 FROM DUAL WHERE ROWNUM < 0;
    no rows selected
    SQL>

  • DUAL Table problem

    As a quick way to grant privileges to almost all the objects in my schema to a role, i created a procedure (Courtesy of user CD from Oracle Forums). But when i executed the below mentioned procedure i got the error :
    ORA-01720: grant option does not exist for 'SYS.DUAL'
    To avoid granting privileges to sys.dual, I tried adding AND OBJECT_NAME < > 'SYS.DUAL' and AND OBJECT_NAME < > 'DUAL' to the query. But that this didn't help.
    But when i query SELECT * FROM DUAL; i can see that DUAL table exists in my schema.
    Any thoughts?
    Here is what i did
    CREATE ROLE newrole;
    DECLARE
    v_sql VARCHAR2(4000);
    BEGIN
    FOR obj IN (SELECT object_name
    , object_type
    , DECODE (OBJECT_TYPE,
    'PROCEDURE','EXECUTE',
    'FUNCTION' ,'EXECUTE',
    'PACKAGE' ,'EXECUTE',
    'SYNONYM' ,'SELECT' ,
    'SEQUENCE' ,'SELECT' ,
    'MATERIALIZED VIEW','SELECT',
    'SELECT, INSERT, UPDATE, DELETE') rights
    FROM user_objects where object_type IN
    ('FUNCTION','PROCEDURE','PACKAGE','SYNONYM','SEQUENCE','MATERIALIZED VIEW','TABLE','VIEW'))
    LOOP
    v_sql := 'GRANT ' || obj.rights || ' ON ' || obj.object_name || ' TO NEWROLE';
    dbms_output.put_line(v_sql);
    EXECUTE IMMEDIATE v_sql;
    END LOOP;
    END;
    /

    One of your views must reference DUAL, perhaps indirectly.
    If this comes up again you can create an exception to catch the error inside the loop for the current item and continue. Not pretty, but it should work something like (untested)
      for record in cursor loop
        --block to catch exception
        declare
           my_error exception;
          --substitute proper error number for -000001 below
          pragma exception_init(-000001,my_error)
        begin
        exception
          when my_error then
            null;
        end;
        --continue processing with next loop item   
      end loop;

  • Sql query and dual table

    Hi,
    1. Do dual table take any physical space in the database or it is only logically present?
    2. Suppose a table contains 100 rows. Write a query to return 42,43,44 rows.
    Thanks,
    Mrinmoy

    user3001930 wrote:
    Hi,
    1. Do dual table take any physical space in the database or it is only logically present?Dual table is physically stored. But starting from 10g (I guess) they indroduced the FAST DUAL access path. Which means if you use the DUAL table not to get the value from the table and only to select a constant value then it will not hit the actually table.
    2. Suppose a table contains 100 rows. Write a query to return 42,43,44 rows.You can use the analytic function ROW_NUMBER for this purpose.

  • How to generate multiple records on a single sql from dual table

    I wanted to generate ten sequence nos in a single sql statement from dual table.
    Is there any way to use that.
    I think somebody can help me on this by using level clause

    I'm not 100% sure if I understand your requirement: Do you really want to use an Oracle Sequence, as Alex already demonstrated?
    Or just a 'one-time-bunch-of-sequential-numbers'.
    In the latter case you can just select level:
    SQL> select level
      2  from   dual
      3  connect by level <= 10;
         LEVEL
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.

  • Use of addImageTheme method with dual table in query

    Is it possible to specify a query using the dual table that specifies a BLOB type? I'm trying to specify a image theme dynamically using the bean API. My image is a JPEG.

    Hi Jen,
    if you create a table with a BLOB to store the image, plus a geometry column with the image MBR, then you can easily build the dynamic image theme using the API. Your SQL on the image theme would be something like: select mbr, image from image_table.
    I'm not sure if there is a direct function at the SQL level that takes an image file and generates a BLOB. Maybe someone has done something similar. If this function exists, then you may be able to create an image theme issuing a SQL with dual table.
    Joao

  • Silly question on dual table

    Hello gurus
    This dual table is a dummy table with varchar2(1)....my question is how it can select many psedocolumns from dual doesn't it exceed the allowed space of varchar2(1)
    Edited by: 964145 on Oct 9, 2012 5:35 PM

    >
    it cannot be a real table
    >
    Not sure why you say that.
    The DDL for it is in the dcore.bsq file (11.2) in the rdbms/admin folder
    create table dual    /* pl/sql's standard pckg requires dual. */
      (dummy varchar2(1))    /* note, the optimizer knows sys.dual is single row */
      storage (initial 1)
    insert into dual values ('X')
    /See the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/queries009.htm#SQLRF20036
    >
    Selecting from the DUAL Table
    DUAL is a table automatically created by Oracle Database 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. Refer to "About SQL Functions" for many examples of selecting a constant value from DUAL.
    >
    And the Database Concepts doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28318/datadict.htm
    >
    The DUAL Table
    The table named DUAL is a small table in the data dictionary that Oracle Database and user-written programs can reference to guarantee a known result. This table has one column called DUMMY and one row containing the value X.
    >
    And those pseudo-columns you ask about
    >
    select sysdate,UID,rowid from dual;
    >
    You can query those from any table but as the doc quote above says you will get as many values as there are rows in the table.

  • Question on dual table..

    after i insert another row into dual table,
    SQL*PLUS still returns only one row. But PL/SQL Developer returns 2 rows.
    What does SQL*PLUS do to return only one row no matter many rows exist in DUAL table?

    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:1562813956388

  • Avoid Hard Parsing for executing dynamic SQL using DUAL table Oracle

    I want to know if dynamic sql statements involving DUAL table can be modified to remove HARD PARSING.
    We have several SQL statements are stored in configuration table, here is sample example
    -- query 1 before replacing index values as stored in config table ---
    select count(*) from dual where  'REPLACE_VALUE_OF_INDEX_3' IN ('K')
    AND (('REPLACE_VALUE_OF_INDEX_13' IN ('1053','1095','1199') ) OR ('REPLACE_VALUE_OF_INDEX_13' IN ('1200') ))
    AND 'REPLACE_VALUE_OF_INDEX_2' IN ('6')
    AND 'REPLACE_VALUE_OF_INDEX_15' IN ('870001305')
    -- query 1 after replacing index values--
    select count(*) from dual where  'REPLACE_VALUE_OF_INDEX_10' IN ('K')
    AND (('1030' IN ('1053','1095','1199') ) OR ('1030' IN ('1200') ))
    AND '2' IN ('6')
    AND 'X' IN ('870001305')
    -- query 2 before replacing index values as stored in config table --
    select count(*) from dual where  'REPLACE_VALUE_OF_INDEX_5' IN ('361A','362A')
    AND 'REPLACE_VALUE_OF_INDEX_22' BETWEEN '200707' AND '200806'
    -- query 2 after replacing index values--
    select count(*) from dual where  '3MAA' IN ('361A','362A') AND '201304' BETWEEN '200707' AND '200806'

    If I got it right you have some (maybe lots of) conditions stored in a table (be patient - it's my interpretation)
    create table eb_conditions as
    select 1 rid,q'{:5 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'}' cndtn from dual union all
    select 2,q'{:2 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'}' from dual union all
    select 3,q'{:1 IN ('K') AND ((:2 IN ('1053','1095','1199') ) OR (:4 IN ('1200') )) AND :3 IN ('6') AND :5 IN ('870001305')}' from dual
    RID
    CNDTN
    1
    :5 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'
    2
    :2 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'
    3
    :1 IN ('K') AND ((:2 IN ('1053','1095','1199') ) OR (:4 IN ('1200') )) AND :3 IN ('6') AND :5 IN ('870001305')
    and you have to check the conditions using values stored in an array
    I used a table instead: the vl at rid = 1 representing the value of bind variable :1 in eb_conditions table and so on ...
    create table eb_array as
    select 1 rid,'K' vl from dual union all
    select 2,'1199' from dual union all
    select 3,'200803' from dual union all
    select 4,'1000' from dual union all
    select 5,'870001305' from dual
    RID
    VL
    1
    K
    2
    1199
    3
    200803
    4
    1000
    5
    870001305
    You want to check the conditions using select count(*) from dual where <condition with binds substituted fron the array>
    Judging from the title Hard Parsing represents the major problem and you cannot avoid it since every condition to be verified is different from every other condition.
    I think your best bet is not to evaluate conditions row by row - context shift cannot be avoided and there might be more than one for each iteration.
    So try to do it in a single step:
    declare
    w_cndtn varchar2(4000);
    w_clob  clob;
    w_cursor sys_refcursor;
    one number;
    two number;
    begin
      dbms_lob.createtemporary(w_clob,false);
      for rw in (select rid,
                        max(cndtn) cndtn,
                        listagg(val,',') within group (order by rn)||',' usng
                   from (select c.rid,c.cndtn,c.rn,c.bind,
                                replace(rtrim(c.bind),':'||to_char(v.rid),''''||v.vl||'''') val
                           from (select rid,
                                        cndtn,
                                        regexp_substr(cndtn,':\d+ ',1,level) bind,
                                        level rn
                                   from eb_conditions
                                 connect by level <= regexp_count(cndtn,':')
                                        and prior rid = rid
                                        and prior sys_guid() is not null
                                ) c,
                                eb_array v
                          where instr(c.bind,':'||v.rid||' ') > 0
                  group by rid
      loop
        w_cndtn := rw.cndtn;
        while instr(w_cndtn,':') > 0
        loop
          w_cndtn := replace(w_cndtn,trim(regexp_substr(w_cndtn,':\d+ ',1,1)),substr(rw.usng,1,instr(rw.usng,',') - 1));
          rw.usng := substr(rw.usng,instr(rw.usng,',') + 1);
        end loop;
        w_cndtn := 'select '||to_char(rw.rid)||' cndtn_id,count(*) from dual where '||w_cndtn||' union all ';
        w_clob := w_clob ||' '||w_cndtn;
      end loop;
      w_clob := substr(w_clob,1,instr(w_clob,'union all',-1,1) - 1);
      open w_cursor for w_clob;
      loop
        fetch w_cursor into one,two;
        exit when w_cursor%notfound;
        dbms_output.put_line(to_char(one)||':'||to_char(two));
      end loop;
      dbms_lob.freetemporary(w_clob);
    end;
    1:0
    2:0
    3:0
    Statement processed.
    Regards
    Etbin

  • How to use dual table in ODI in source side for nested queries?

    Hi,
    Any idea how to use dual table in source for more than once. I want to build a ODI interface for the following source query
    SELECT ACTV_TYP.ACTV_TYP_SRC_CD, ACTV_TYP.ACTV_TYP, PORT_ACTV_TYP.PORT_ACTV_TYP_SRC_CD, PORT_ACTV_TYP.PORT_ACTV_TYP, SFT_DLT_STS.SFT_DLT_STS_SRC_CD, SFT_DLT_STS.SFT_DLT_STS
    FROM
    SELECT LOW_VALUE PORT_ACTV_TYP_SRC_CD, MEANING PORT_ACTV_TYP
    FROM CUSTOMS.DOMAIN_ALLOW_COLUMNS_VALUES
    WHERE TABLE_NAME = 'BRKR_PORTS'
    AND COLUMN_NAME = 'WORK_PORT_TYPE') PORT_ACTV_TYP,
    (SELECT LOW_VALUE SFT_DLT_STS_SRC_CD, MEANING SFT_DLT_STS
    FROM CUSTOMS.DOMAIN_ALLOW_COLUMNS_VALUES
    WHERE TABLE_NAME = 'BANKS'
    AND COLUMN_NAME = 'REC_STATUS') SFT_DLT_STS,
    (SELECT 1 ACTV_TYP_SRC_CD, '?????' ACTV_TYP FROM DUAL
    UNION ALL
    SELECT 2 ACTV_TYP_SRC_CD, '???????' ACTV_TYP FROM DUAL) ACTV_TYP
    Regards

    If the below query is equivalent , it seems you don't need dual table at all , just default the values in the interface.
    You are using dual tables to populate values ACTV_TYP.ACTV_TYP_SRC_CD, ACTV_TYP.ACTV_TYP values. Look at your query in the following manner :
    SELECT '1', '?????', PORT_ACTV_TYP.PORT_ACTV_TYP_SRC_CD, PORT_ACTV_TYP.PORT_ACTV_TYP, SFT_DLT_STS.SFT_DLT_STS_SRC_CD, SFT_DLT_STS.SFT_DLT_STS
    FROM
    SELECT LOW_VALUE PORT_ACTV_TYP_SRC_CD, MEANING PORT_ACTV_TYP
    FROM CUSTOMS.DOMAIN_ALLOW_COLUMNS_VALUES
    WHERE TABLE_NAME = 'BRKR_PORTS'
    AND COLUMN_NAME = 'WORK_PORT_TYPE') PORT_ACTV_TYP,
    (SELECT LOW_VALUE SFT_DLT_STS_SRC_CD, MEANING SFT_DLT_STS
    FROM CUSTOMS.DOMAIN_ALLOW_COLUMNS_VALUES
    WHERE TABLE_NAME = 'BANKS'
    AND COLUMN_NAME = 'REC_STATUS') SFT_DLT_STS
    UNION
    SELECT 2 , '??????', PORT_ACTV_TYP.PORT_ACTV_TYP_SRC_CD, PORT_ACTV_TYP.PORT_ACTV_TYP, SFT_DLT_STS.SFT_DLT_STS_SRC_CD, SFT_DLT_STS.SFT_DLT_STS
    FROM
    SELECT LOW_VALUE PORT_ACTV_TYP_SRC_CD, MEANING PORT_ACTV_TYP
    FROM CUSTOMS.DOMAIN_ALLOW_COLUMNS_VALUES
    WHERE TABLE_NAME = 'BRKR_PORTS'
    AND COLUMN_NAME = 'WORK_PORT_TYPE') PORT_ACTV_TYP,
    (SELECT LOW_VALUE SFT_DLT_STS_SRC_CD, MEANING SFT_DLT_STS
    FROM CUSTOMS.DOMAIN_ALLOW_COLUMNS_VALUES
    WHERE TABLE_NAME = 'BANKS'
    AND COLUMN_NAME = 'REC_STATUS') SFT_DLT_STS
    Now you can use dataset to make UNION.

  • Doubts about Temporary Table.

    Hi,
    I am using Temporary Table.
    But the insert command takes too much time compare to insert in Normal table.
    One more doubt about Temporary Table is:
    Suppose there are two different users. They connect and first insert rows of their use .Now they go for select.
    Does select of one user goes to check the rows of second user also or the temporary table treats 2 users data as inserted in 2 different tables?
    Help!!!

    Nested structure (not deep - deep means their a string or a table as a component)
    TYPES: BEGIN OF tp_header_type,
             BEGIN OF d,
               empresa TYPE ...
               num_docsap TYPE ...
            END OF d,
            awkey TYPE ...
          END OF tp_header_type.
    matt

  • Dual table in 10g

    Hi!
    1 am using forms 6.
    my forms were running good but after i take my application to 10g, some forms have not been compiling.
    in every form where dual table has been referenced error has come, remaining forms run well
    like
    select sysdate
    into l_Date
    from dual
    if in form i use sys.dual then it works
    in sql plus i can select using select * from dual
    is this a bug or any other problem?
    thanx

    error has comeGive us a clue. What error? Please post error number and message or at least describe the behaviour.
    Also, this is primarily a database forum. As your queries run in SQL*Plus it strikes me this is most likely to be a problem with Forms, and so you may be better off trying the OTN > Products > Developer Suite > Forms forum. Unlike this forum, actual Oracle employees answer questions there, so it's definitely a better bet.
    Are you using Forms 6 or 6i? Forms 6 is de-supported and so may not play nicely with 10g. 6i is supported and either is or will be certified to run against 10g.
    Cheers, APC

  • PLSQL Dual table problem

    Were having strange problems using ther dual tables as below:-
    selecting sysdate from dual via a sql session the results are returned as expected, but when placing the select sysdate from dual within a PLSQL block we seem to get booted out of the system, and lose the connection to oracle.
    Tried re-booting the database, had no impact.
    any ideas out there?
    Thanks.
    null

    Hey this is a very strange problem. anyway what i would suggest is to use the direct references of the system variables and avoid using DUAL.
    for example :
    datefield := sysdate;
    U assign the sysdate to variable. Like this u can do for sequence etc...
    Vijay
    null

  • Question about dual table

    Hi,
    Can anyone clarify me this
    Can I insert rows into dual table (being a programmer) ?? Using oracle 9i ... If no, can DBA do that ??? Say suppose, I have inserted 100 records in the dual table .. In any way, my applications are going to get hampered after inserting the records in the dual table
    Regards

    Or perhaps this:
    SQL> SELECT * FROM
      2  ( select rownum from dual connect by rownum <= 10 );
        ROWNUM
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.In 9i at least you most certainly can insert into sys.dual, which is a regular table in the SYS schema, although you deserve all you get if you do so:
    /Users/williamr: su - oracle
    Password:
    /Users/oracle: sqlplus '/ as sysdba'
    SQL*Plus: Release 9.2.0.1.0 - Developer's Release on Fri Mar 10 19:21:45 2006
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Developer's Release
    With the Partitioning and Oracle Data Mining options
    SQL> SELECT COUNT(*) FROM sys.dual;
      COUNT(*)
             1
    1 row selected.
    SQL> INSERT INTO dual VALUES ('Z');
    1 row created.
    SQL> SELECT COUNT(*) FROM sys.dual;
      COUNT(*)
             2
    1 row selected.
    SQL> set serverout on
    SQL> EXEC DBMS_OUTPUT.PUT_LINE(user);
    BEGIN DBMS_OUTPUT.PUT_LINE(user); END;
    ERROR at line 1:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at "SYS.STANDARD", line 264
    ORA-06512: at line 1
    SQL> roll
    Rollback complete.
    SQL> EXEC DBMS_OUTPUT.PUT_LINE(user);
    SYS
    PL/SQL procedure successfully completed.
    SQL> So it is technically possible, but monumentally inadvisable to mess about with sys.dual.
    For a rather surreal suggestion related to this scenario, see:
    oracle-wtf.blogspot.com/2006/03/create-your-own-dual-table.html

Maybe you are looking for

  • How to find out the path of already existing directory?

    I need to get the exact path of 'FCO_DIR' directory. Could you please help me out with this. Is there any table name or a quey that I can run to get this information? Below is the code that I am using : Code: l_input_dir CONSTANT VARCHAR2 (30) := 'FC

  • Urgent: Failed to read WSDL

    Hi, I am getting error in our production system similar to below error whenever the load in the server is very high. How do I resolve this problem? The process domain encountered the following errors while loading the process "myOrderBooking" (revisi

  • OLE DB source to connect to teradata and need to send a paramter in query

    Hi SSIS gurus, I am using OLEDB source to connect to Teradata and need to pass a parameter to the query. Ex: Select * from MyTable where NoOfyrs = 'MyParameter' VS2010 version, SQL server 2012, Teradata version 14.10 I have tried all the below option

  • Creating a uniform border as a percentage of image size. How?

    I am wanting to build a script that will allow me to add a black border measuring a uniform width (say 5% of the picture height) for a batch of images of different resolutions and sizes. Problem is, increasing the canvas size by +5% black on a rectan

  • VERY weird bug

    on my stage, i've got a viewstack and two canvases to it. on canvas 2 is txtQuestion. when i reference txtQuestion like so if(quizQuestions.length >= currentQ) { Alert.show(txtQuestion.toString()); txtQuestion.text = quizQuestions[currentQ]; } else {