Convert Between an In-Memory Table and an Extended Table
- How to convert an in-memory column store table to an extended table and vice versa.
- Tutorials: Create Tables and Import Data
- Step 1
Right-click on your database, and select Open SQL Console. You can also use the shortcut Ctrl + Alt + C or the SQL button under the navigation menu.
Copy and paste the script below into the console, and press then green play button to execute the script.SQLCopy
ALTER TABLE "TPCH"."NATION_DT" NOT USING EXTENDED STORAGE
Go back to the Tables tab and click the refresh icon. You should see that the
NATION_DTtable is no longer an
EXTENDEDtable, and is now an in-memory table.
- Step 2
Open a new SQL console and paste the script below into the console. Then press the play button to execute and run the script.SQLCopy
ALTER TABLE "TPCH"."NATION_DT" USING EXTENDED STORAGE
Notice that the difference between the “
ALTER TABLE” statement here and the previous section is the removal of “
Go back and refresh the Tables tab. You should see that the
NATION_DTtable is no longer an in-memory database, as it has the
- Step 3
In SAP HANA 2.0, dynamic tiering tables do not support foreign keys between two extended tables or between an extended table and an in-memory table. This means that if an in-memory table is part of a foreign key relationship, then it cannot be converted to an extended table in dynamic tiering until the foreign key relationship has been dropped.
Since dynamic tiering tables do not support foreign keys yet, the change from an extended table to in-memory is always possible (because extended tables would not have any foreign key attached to them), but in-memory to extended storage might be restricted due to foreign key constraints.
You can verify which tables in the
TPCHschema are part of a foreign key constraint by executing the following statement in a SQL Console:SQLCopy
SELECT * FROM "SYS"."REFERENTIAL_CONSTRAINTS" WHERE SCHEMA_NAME='TPCH'
You can look at the columns:
CONSTRAINT_NAMEto identify which tables have the foreign key constraint on them and what the constraint is. Examples of tables that hold a foreign key constraint in this schema are
NATION_CS. Therefore, these tables cannot be converted to extended tables, unless the foreign key is dropped.
An extended table can ALWAYS be converted to an in-memory table: