Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

During development, it's common to want to remove all data from a data location in order to reload it. Use cases:

  • Matching or Consolidation rules have changed, and you want to apply those changes.
  • Hard-deleting all the data from the data location.

Generate truncate statements in Oracle like this:

Truncate Data Location Tables
select 'truncate table MY_SCHEMA.' || table_name || ';' as generated_statements
from all_tables 
where
  owner = 'MY_SCHEMA'               /* set this to your data location schema */
  and table_name not like 'DL_%'    /* do not truncate these system tables   */
  and table_name not like 'EXT_%'   /* do not truncate these system tables   */
  and table_name like '%ENTITYNAME' /* edit these filters as needed          */
order by substr(table_name,3), table_name;

It will give you runnable SQL like this:

Truncate statements
truncate table MY_SCHEMA.GD_STORE;
truncate table MY_SCHEMA.GE_STORE;
truncate table MY_SCHEMA.GI_STORE;
truncate table MY_SCHEMA.MD_STORE;
truncate table MY_SCHEMA.MI_STORE;
truncate table MY_SCHEMA.SD_STORE;
truncate table MY_SCHEMA.SE_STORE; 

Generate truncate statements in PostgreSQL:

Truncate Data Location Tables for Postgres
select 'truncate table my_schema.' || tablename || ';' as generated_statements
from pg_catalog.pg_tables 
where schemaname = 'my_schema'      /* set this to your data location schema */
  and tablename not like 'dl_%'     /* do not truncate these system tables   */
  and tablename not like 'ext_%'    /* do not truncate these system tables   */
  and tablename ilike '%entityname' /* edit these filters as needed          */
order by substr(tablename,3), tablename;

Generate truncate statements in SQL Server:

Truncate statements for SQL Server
SELECT 'truncate table ' + TABLE_NAME + ';' 
FROM SEMARCHY_PRODUCT_RETAIL_MDM.INFORMATION_SCHEMA.TABLES   /* amend Database Name to your database */
WHERE TABLE_NAME NOT LIKE 'DL_%' 
AND   TABLE_NAME NOT LIKE 'EXT_%'   /* Don't truncate these Semarchy system tables starting with DL and EXT */
AND   TABLE_NAME LIKE '%BRAND'      /* amend this line to meet your needs */
ORDER BY SUBSTRING(TABLE_NAME, 1, 3), TABLE_NAME
;

It will give you SQL statements to run against the particular database:

Example
truncate table AE_BRAND;
truncate table GD_BRAND;
truncate table GH_BRAND;
truncate table GX_BRAND;
truncate table SA_BRAND;

This technique only removes the data, but does not remove the data structures (tables). For that purpose, you must drop the data location. This is great when you really want to start completely fresh, but you must use this option carefully. This is done from the Data Locations tab in the workbench.

Filter by label

There are no items with the selected labels at this time.

  • No labels