I would like to take a snap shot of my db at a time of my choosing, so I can go back to that point if my tests mess up.
Is there a simple sql command that will clone a table, with data, to a new table?
Is there an easy way to b/u the db with code, and then restore simply?
Hi
in my case i wanted give sync functionality to the end users, they want to sync production , test or any other data with each other.
you basically need to create different schema’s for each environment. i use Azure SQL.
you can script your tables and then create them in another schema. All sync is done on the database side using a stored procedure. this procedure is on my github repository.
i have a form app to sync tables . Table names are stored in {tables} field, coma separated.
there is a php button that runs this php
$schema_from=’’;
$schema_to=’’;
$m=’’;
echo ‘START SYNC AT ‘. date(“Y-m-d H:i:s”).’ ’;
// Check for record
$check_sql = “SELECT connection_schema from sec_connections where connection_guid=’”.{connection_from_guid}."’";
sc_lookup(rs, $check_sql);
if (isset({rs[0][0]})) // Row found
{
$schema_from={rs[0][0]};
}
$check_sql = “SELECT connection_schema from sec_connections where connection_guid=’”.{connection_to_guid}."’";
sc_lookup(rs, $check_sql);
if (isset({rs[0][0]})) // Row found
{
$schema_to={rs[0][0]};
}
$m=‘sync tables from schema ‘.$schema_from.’ to schema ‘.$schema_to.’ ’;
$table=explode(",", {tables});
foreach ($table as $t) {
if($t>’’ && $schema_from>’’ && $schema_to>’’ && $schema_from<>$schema_to){
$m=$m.‘sync table ‘.$t.’ AT ‘. date(“Y-m-d H:i:s”).’ ’;
Good luck, it is pretty amazing that database do not let you simply make a copy of a table similar to files but require all this heavy lifting.
we come from a really weird world.