Skip to main content
16-Pearl
July 15, 2024
Question

How to copy data including the meta data from a data table to another data table

  • July 15, 2024
  • 2 replies
  • 2170 views

I've tried duplicating the data table entity in composer, but it did not copy the data over.  If I use the service AddDataTableEntries, to import the data as an infotable, it does not copy the meta data.  Is there a way to copy data including the meta data from a data table to another data table?  I need a data table with the same data, but with a different data table name.

2 replies

16-Pearl
July 17, 2024

What metadata are you referring to here?

You can check the article CS330382 at https://www.ptc.com/en/support/article/cs330382

This article is for Stream, it should work for Datatable if you replace GetStreamEntriesWithData with QueryDataTableEntries of Datatable and AddStreamEntry with AddDataTableEntry of Datatable

 

Willie16-PearlAuthor
16-Pearl
July 17, 2024

@Jimwang 

Thank you for sharing the article.  I will give that a try.    By meta data, I meant timestamp, source, tags, etc.

5-Regular Member
July 17, 2024

Hello @Willie 

This can be done by using SQL database query. You can create a new datatable and also create a datatable with similar name in composer to be a duplicate of your source datatable. 

 

Hope this helps! Pls let me know if you face any further challenges.

 

Regards,

Bhawna

 

 

Willie16-PearlAuthor
16-Pearl
July 17, 2024

@bchaudhary_448008 

 

I found the following Postgres queries to work for this task:

Copying:

INSERT INTO data_table (entity_id, entity_key, field_values, location, source_id, source_type, tags, "time", full_text) SELECT 'TargetDataTableName' AS entity_id, entity_key, field_values, location, source_id, source_type, tags, "time", full_text FROM data_table where entity_id='SourceDataTableName';

 

Verifying:

select * from data_table where entity_id= 'TargetDataTableName';