{"id":132,"date":"2010-08-06T16:17:09","date_gmt":"2010-08-06T20:17:09","guid":{"rendered":"http:\/\/www.dev-notes.com\/blog\/2010\/08\/06\/using-dummy-table-to-select-pseudocolumns\/"},"modified":"2010-08-06T16:17:09","modified_gmt":"2010-08-06T20:17:09","slug":"using-dummy-table-to-select-pseudocolumns","status":"publish","type":"post","link":"https:\/\/www.dev-notes.com\/blog\/2010\/08\/06\/using-dummy-table-to-select-pseudocolumns\/","title":{"rendered":"Using dummy table to select pseudocolumns"},"content":{"rendered":"<p>In Oracle, the dummy table is &#8220;dual&#8221;.  It is present in all Oracle database installations, thus no special setup is needed to use it.  Below are some samples on how to use this table.<\/p>\n<pre class=\"code\">\n-- Getting the current system date:\n\nPROMPT> select sysdate from dual;\n\nSYSDATE\n---------\n06-AUG-10\n\n-- Getting the current logged-in user:\n\nPROMPT> select user from dual;\n\nUSER\n------------------------------\nYTCDBA\n\n-- Display the result of some string manipulation\n\nPROMPT> select substr('hello world',1,7) from dual;\n\nSUBSTR(\n-------\nhello w\n<\/pre>\n<p>The DB2 equivalent of Oracle&#8217;s &#8220;dual&#8221; is &#8220;sysibm.sysdummy1&#8221;.  Below is a sample of the usage.<\/p>\n<pre class=\"code\">\n-- Getting the current system date:\n\nPROMPT> select current date from sysibm.sysdummy1;\n\n00001\n----------\n2010-08-06\n\n-- Getting the current logged-in user:\n\nPROMPT> select current user from sysibm.sysdummy1;\n\n00001\n-----\nUSER1\n\n-- Display the result of some string manipulation\n\nPROMPT> select substr('hello world',1,7) from sysibm.sysdummy1;\n\n00001\n-------\nhello w\n<\/pre>\n<p>It is also worthy of note that MySQL and SQL Server can select pseudocolumn data without the use of a dummy table.  For example, in SQL Server, you can get the current date by running &#8220;select getdate();&#8221; without a &#8220;from&#8221; clause in your SQL statement.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This note illustrates how to use a dummy table to select pseudocolumns in Oracle and DB2 databases.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,20],"tags":[],"class_list":["post-132","post","type-post","status-publish","format-standard","hentry","category-db2","category-oracle"],"_links":{"self":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/comments?post=132"}],"version-history":[{"count":0,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/132\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/media?parent=132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/categories?post=132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/tags?post=132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}