Skip to main content
Nov 16, 2018 12:25 PM UTC
Solved

in Thingworx How to archive data table everyday since two years?

I have created table1 for daily direction in "Mysql workbench 6.3 CE" with 11 Rows , I want to archive all data table in another table archive every day since 2 years to have all history. How can I write such a table?

This the table script:

CREATE TABLE ``table1(
IDINT(11) NOT NULL,
tskVARCHAR(200) NULL DEFAULT NULL,
labelVARCHAR(45) NULL DEFAULT NULL,
statVARCHAR(10) NULL DEFAULT NULL,
noteVARCHAR(200) NULL DEFAULT NULL,
dateVARCHAR(45) NULL DEFAULT NULL,
recVARCHAR(45) NULL DEFAULT NULL,
 PRIMARY KEY (ID),
 UNIQUE INDEXID_UNIQUE(ID` ASC));
Dec 22, 2018 8:14 AM UTC

Hello Everyone,

 

we use coding 

- API to set all table status by default Open 

- set API Loop all Rows if User change status from Open to any other word it will move the row in to another table

 

 

4 replies

Nov 16, 2018 7:40 PM UTC

Hello.

 

I gather you are using MySQL for your persistent storage?

 

Have you tried something like this?

 

Disclaimer: this comes from a 3rd-party MySQL support area, and not from PTC. Use at your own risk and on a test system before trying it in production.

 

Suppose you have mydb.mytb and you want to create mydb.mytbcopy

In the mysql client, run the following

USE mydb
CREATE TABLE mytbcopy LIKE mytb;
INSERT INTO mytbcopy SELECT * FROM mytb;

 

Thanks,

 

-- Craig A.

 

 
Nov 17, 2018 12:13 PM UTC

Hello Craig ,

Thanks for Reply

 

I gather you are using MySQL for your persistent storage? Yes , i use MySql Workbench 6.3 CE

 

in attached pic from the DB where i supposed to write this code ?

 

 

 

 

 

Dec 5, 2018 8:37 PM UTC

Hello.

 

Based on the picture you attached and your earlier post, it looks like your earlier CREATE statement should be used to create the backup (copy-to) table and then the SELECT statement that's in your screen grab would be included inside the INSERT INTO statement.

 

Thanks,

 

-- Craig A.

Islam_AmerAuthorAnswer
Dec 22, 2018 8:14 AM UTC

Hello Everyone,

 

we use coding 

- API to set all table status by default Open 

- set API Loop all Rows if User change status from Open to any other word it will move the row in to another table