Rank: Member
Joined: 8/28/2009(UTC) Posts: 29
|
Hi, does anyone have a sql script to purge old records from the database? Thanks.
|
|
|
|
Rank: Member
Joined: 9/26/2008(UTC) Posts: 121
|
Hi, If you want to remove all records from table you can write such simple sql script: delete table-name. But such table has relations with others it might be necessary to delete records from other tables. |
|
|
|
|
Rank: Member
Joined: 8/28/2009(UTC) Posts: 29
|
Right, I want to figure out all the tables I should delete the records from.
|
|
|
|
Rank: Member
Joined: 6/28/2010(UTC) Posts: 38
|
In the old days we had a database diagram to show all of the table relationships. If you dont have one of those, you need to look through all of the SQL code to see how the tables are related and which rows need to be deleted in all the related tables, if you want to clear out rows in another table.
Your database may be set up with constraints that will throw errors if you try to clear a table.
|
|
|
|
Rank: Member
Joined: 11/5/2003(UTC) Posts: 1,786
|
We do not recommend deleting or adding records directly in the database. Although this can be useful it is much safer and easier to write a small web page with a button. On the button click call into our APIs and delete the items you're interested in.
For example (this is in pseudo code so it's not literal)
For each Product p in Catalog.Products.FindAll() { Delete p; }
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.