Current Position:Home > Doubt in DUAL TABLE

Doubt in DUAL TABLE

Update:10-11Source: network consolidation
Advertisement
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.

The Best Answer

Advertisement
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.
  • Doubt in DUAL TABLE Update:10-11

    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?    Typ

  • How to return number range from sql (dual table) Update:10-11

    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 n