3

I am trying to select now() from my local postgres database dual table:

select now() from dual;

It returns no rows. Just prints column name now(yyyy-MM-dd HH:mm:ss.ffffff)

What is it that I am missing that it cannot get the system time?

Hannah Vernon
71.1k22 gold badges178 silver badges323 bronze badges
asked Oct 5, 2017 at 20:13

1 Answer 1

7

Don't create dual tables

Why are you using a dual table in PostgreSQL to begin with? PostgreSQL has an implicit dual table if there is no from-clause.

SELECT now(); -- works fine.

You can also

SELECT * FROM now(); -- works fine.

Creating a dual table should still work

You'll never need a dual table with PostgreSQL, and you shouldn't create one: it just convolutes the syntax. It's also foreign for most PostgreSQL users. That said, it's easy to demonstrate that it works..

test=# CREATE TABLE dual AS ( VALUES (true) );
SELECT 1
test=# SELECT now() FROM dual ;
 now 
-------------------------------
 2017年10月05日 15:34:34.359092-05
(1 row)
answered Oct 5, 2017 at 20:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.