Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do "select current_timestamp" in hsqldb?

Oracle:

select systimestamp from dual

MySQL:

select current_timestamp

SQL Server:

select current_timestamp

PostgreSQL:

select current_timestamp

The question is, how can I get the current timestamp in HSQLDB? I use version 1.8.0.10

like image 200
cherouvim Avatar asked May 26 '09 09:05

cherouvim


People also ask

What is Hsqldb in memory database?

HSQLDB (HyperSQL DataBase) is the leading SQL relational database system written in Java. It offers a small, fast multithreaded and transactional database engine with in-memory and disk-based tables and supports embedded and server modes. It includes a powerful command line SQL tool and simple GUI query tools.

How do I open Hsqldb in browser?

Enter your query in the Textbox at the upper right-hand side of the window and click on the "Execute SQL" button to run the query. Once done close the HSQL Database Manager and delete the database. lck file from the <collab-server install dir>/tomcat/ directory. Start the ccollab-server daemon/service.


2 Answers

In a select I use

 SELECT CURRENT_DATE AS today, CURRENT_TIME AS now FROM (VALUES(0))
like image 152
jeanlou1370 Avatar answered Sep 20 '22 09:09

jeanlou1370


@alexdown's answer is quite right -- under 1.8 you need a one-row relation to do this, like Oracle's DUAL or the InterBase/Firebird RDB$DATABASE table.

When you move to the 2.0 series, however, you'll be able to use the SQL-99 "VALUES constructor" without reliance on a one-row relation:

sql> VALUES (current_timestamp);
2010-04-22 15:22:40.997

If you need to rename the column from the vendor-specific defaults that VALUES picks, you can always employ a select: SELECT * FROM (VALUES (current_timestamp)) v(my_new_name)

like image 27
pilcrow Avatar answered Sep 19 '22 09:09

pilcrow