As this is the first in series, I will be concentrating on the following topics:
A primer on the “dual” table in Oracle This section mainly explains the “dual” table in Oracle. I shall use this table in a creative manner wherever required in this article as well as upcoming articles. If you are already familiar with the "dual” table, feel free to skip to the next section. What is a “dual” table? It is a simple table which is created/installed automatically during the installation of the Oracle database. To understand it, let us consider the following SELECT statement: SELECT 123 FROM dual; The above statement simply returns 123. Let us work with another statement: SQL> SELECT 10,20,'Jagadish Chatarji',3400 FROM dual; 10 20 'JAGADISHCHATARJI' 3400 ----- ----- ------------------ ---------------------- 10 20 Jagadish Chatarji 3400 1 rows selected This returns any constant values you provide as columns. So “dual” is just a convenience table. It is simply a one column and one row table that exists as part of SYS user. You can use the DESC command to display the structure of a “dual” table as follows: DESC dual; The above statement returns the following output:
You can observe that there exists only one column named “dummy” in the "dual" table. Similarly, you can even display all the rows in the "dual" table as follows: SQL> SELECT * FROM dual; DUMMY ----- X 1 rows selected From the above, you can observe that there exists only one row with a dummy value of "x." You don't really need to use the “dual” table at all. It is only used when you want to add/include any constant values in your queries. You can even do calculations as follows: SQL> SELECT 12 * 13 + 14 FROM dual; 12*13+14 ---------------------- 170 1 rows selected
blog comments powered by Disqus |
|
|
|
|
|
|
|