Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: DBI/MySQL/MariaDB clone tables across DB Connections

by Bod (Parson)
on Apr 06, 2023 at 21:37 UTC ( [id://11151495]=note: print w/replies, xml ) Need Help??


in reply to Re^2: DBI/MySQL/MariaDB clone tables across DB Connections
in thread DBI/MySQL/MariaDB clone tables across DB Connections

I would go the route of dumping things to files and then importing from files

This is the way I would usually go...but...
be aware that it is a great pain if you are using MariaDB System Versioned tables.

mysqldump will dump the current data but not the historic data and recreating the historic data is a pain as I have found to my cost.

I made a bad design decision to use 'email' as a primary key on a database where users can have multiple email addresses stored. I don't know what possessed me not to use a system-generated key but I did. I only realised once there was data in the data - both current and historic. I could not find a way to add a field with AUTO_INCREMENT so I ended up copying the current data to a new table, dropping the offending table, rebuilding it with a generated primary key and then reimporting the data to the table. But, being system versioned, I lost all the historic data.

This wasn't the end of the world as it was all test data. Recently, the production database has been built but not before carefully checking every table for similar traps. I found one - using phone numbers as a primary key!

It should be possible to restore historical data to system versioned tables by setting the @@timestamp variable but I've not tried it yet. Once I have the production system up and working (launch date is next Monday), I will test writing a backup and restore utility that plays with @@timestamp to properly restore system versioned tables.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11151495]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-19 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found