Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boolean column in HSQLDB with default value

Tags:

java

hsqldb

I have having trouble getting HSQLDB to create a table with a boolean column. It seems every time I try to specify a default, I get the exception:

org.hsqldb.HsqlException: unexpected token: DEFAULT

I can create this problem even with this trivial table definition:

CREATE TABLE foo (
  bar BOOLEAN NOT NULL DEFAULT FALSE
);

According to the documentation, I should be able to do this!

See columnDefinition in http://www.hsqldb.org/doc/guide/ch09.html#create_table-section

Have I misunderstood something here?

like image 368
NickJ Avatar asked Aug 26 '13 17:08

NickJ


People also ask

What is the value of Boolean by default?

The default value of Boolean is False .

What is the use of HSQLDB?

HSQLDB is used for development, testing, and deployment of database applications. The main and unique feature of HSQLDB is Standard Compliance. It can provide database access within the user's application process, within an application server, or as a separate server process.

How do I open HSQLDB in browser?

Open the “Data Source Explorer” view using Window > Show view > Other and create a new Database Connection. Choose HSQLDB from the list of Connection Profile Types and provide a name, e.g. Library. Next, add a New Driver Definition and specify hsqldb. jar in the JAR List tab.


1 Answers

From the HSQLDB doc provided, the correct syntax is

CREATE TABLE foo (
  bar BOOLEAN DEFAULT FALSE NOT NULL
);

i.e. The order matters in the SQL

like image 185
Reimeus Avatar answered Sep 23 '22 10:09

Reimeus