I am trying to create a new table from the result of a select. This works fine with SQL Server:
SELECT * INTO newTable FROM (SELECT col1, col2, col3 FROM oldTable) x;
Now, I want to achieve the exact same thing with HSQLDB (Version 2.2). I have tried several forms like
SELECT * INTO newTable FROM (SELECT col1, col2, col3 FROM oldTable);
SELECT INTO newTable FROM SELECT col1, col2, col3 FROM oldTable;
CREATE TABLE newTable AS SELECT col1, col2, col3 FROM oldTable;
All these variants result in some form of syntax error. How can I create a table from a select with HSQLDB?
HSQLDB - Select Query. The SELECT command is used to fetch the record data from HSQLDB database. Here, you need to mention the required fields list in the Select statement. Syntax. Here is the generic syntax for Select query.
The SELECT command is used to fetch the record data from HSQLDB database. Here, you need to mention the required fields list in the Select statement. Here is the generic syntax for Select query. SELECT field1, field2,...fieldN table_name1, table_name2...
HSQLDB does not currently enforce the SQL 200n proposed rules on where sequence generated values are allowed to be used. In general, these values can be used in insert and update statements but not in CASE statements, order by clauses, search conditions, aggregate functions, or grouped queries. Strings in HSQLDB are Unicode strings.
Permission is granted to distribute this document without any alteration under the terms of the HSQLDB license. $Date: 2007/08/28 12:13:28 $ Table of Contents Introduction Available formats for this document 1. Running and Using Hsqldb Introduction Running Tools Running Hsqldb Server Modes Hsqldb Server Hsqldb Web Server Hsqldb Servlet
The manual has an example for this:
CREATE TABLE t (a, b, c) AS (SELECT * FROM atable) WITH DATA
HSQLDB requires parentheses around the select (unlike all other DBMS) and it also requires the WITH DATA
clause
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With