Search code examples
db2

How i can create a table using AS and specify the tablespace in db2?


I'm trying to create a table using "AS" and specify the tablespace. I tried something like:

db2 "CREATE TABLE schema.table AS (SELECT * FROM schema.tmp) IN TABSPACE01 WITH NO DATA"

But i get a error, it's possible to specify the tablespace when creating a table with "AS"?


Solution

  • When using a result set to create a table WITH NO DATA should follow immediately after the fullselect.

    db2 "CREATE TABLE schema.table AS (SELECT * FROM schema.tmp) WITH NO DATA IN TABSPACE01"