Any way to move existing table to new schema?

343 views
Skip to first unread message

Mateusz

unread,
Jun 28, 2011, 5:10:46 AM6/28/11
to H2 Database
Hi,

is there any way in H2 database to move existing tables to different
schema. For example, I have one table 'TABLE_A' with some data in
default schema PUBLIC.
I created new schema MY_SCHEMA and want to move TABLE_A and all of its
content to schema MY_SCHEMA.

I tried:
UPDATE INFORMATION_SCHEMA.TABLES SET TABLE_SCHEMA = 'MY_SCHEMA' WHERE
TABLE_SCHEMA = 'PUBLIC' AND TABLE_NAME = 'TABLE_A'

but I got:
Feature not supported: "META"; SQL statement: [...]

Thanks in advance for any help
Matthew

Bryan

unread,
Jun 28, 2011, 11:56:49 AM6/28/11
to H2 Database
On Jun 28, 4:10 am, Mateusz <mateusz.grzechocin...@gmail.com> wrote:

> is there any way in H2 database to move existing tables to different
> schema.

I am new to H2 and am not where I can try it, but did you try
something like this?

CREATE TABLE my_schema.table_a
AS SELECT * FROM public.table_a;

And then drop the old one in public?

Igal

unread,
Jun 18, 2012, 3:58:51 PM6/18/12
to h2-da...@googlegroups.com
I just tried it and it works fine.  obviously only the data is copied over (no indexes etc).

it was good enough for my purpose though.
Reply all
Reply to author
Forward
0 new messages