简体   繁体   English

HSQLDB中的SELECT UUID()

[英]SELECT UUID() in HSQLDB

Does anyone know how to retrieve UUID via HSQLDB. 有谁知道如何通过HSQLDB检索UUID。

For example when i try 例如当我尝试

SELECT UUID();

via MYSQL it works fine. 通过MYSQL可以正常工作。 But the same statement doesn't work with HSQLDB. 但是同一条语句不适用于HSQLDB。 The following methods achieve the corresponding purpose 以下方法达到了相应的目的

VALUES (UUID())

CALL(UUID())

SELECT UUID() FROM (VALUES(0)) t;

Is there a way which is same for mysql and hsqldb? 有没有办法与mysql和hsqldb相同? HSQL doc says that UUID has been activated. HSQL文档说UUID已被激活。 http://hsqldb.org/doc/guide/builtinfunctions-chapt.html http://hsqldb.org/doc/guide/builtinfunctions-chapt.html

Thanks. 谢谢。

Turn on the MySQL compatibility mode in HSQLDB and it will allow your SELECT statement: 在HSQLDB中打开MySQL兼容模式,它将允许您的SELECT语句:

http://hsqldb.org/doc/2.0/guide/compatibility-chapt.html#coc_compatibility_mysql http://hsqldb.org/doc/2.0/guide/compatibility-chapt.html#coc_compatibility_mysql

Is there a way which is same for mysql and hsqldb? 有没有办法与mysql和hsqldb相同?

Only way i can think off. 只有这样我才能考虑。
Create a table DUAL in HSQLDB 在HSQLDB中创建表DUAL

CREATE TABLE DUAL (
  id INT
);

So you can use 所以你可以使用

SELECT UUID() FROM DUAL LIMIT 1;

Then the query should work the same in both MySQL and HSQLDB. 然后,该查询在MySQL和HSQLDB中均应相同。
DUAL in MySQL is a non existing dummy table. MySQL中的DUAL是不存在的虚拟表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM