How to move a DB2 database structure and data without contraint issues - sql

I want to move a DB2 10.1 database schema including tables, view, keys, sequences and its data to a new database on another network.
The new database is in a Production environment and because of security protocols, I cannot copy it directly across the networks. The current database is in a non-Production test environment.
I'm looking to generate script or scripts which will recreate the database schema including the tables, view, keys, sequences and its data. These scripts can then be transferred to the other network and run from there.
How can I do this? I have looked at db2move and db2look, but this looks like I will have problems when inserting the data because of referential constraints and the sequencing of primary keys (want to keep the current key id as it is being used as a reference number by the business team, but it is auto generated in the database).
Thanks

Related

Have to make all existing GUIDs in a database unique again. Is there a mathematical operation to do this?

We have a database which was at one point a copy of our current Production DB. Therefore some GUIDs are not unique between databases. We are now using a provider which does not have a sandbox for preproduction/testing, so the two databases access the provider data, causing collisions.
Is there a mathematical operation to apply to all guids in the non-production database to transform them determinately? Unfortunately there are some instances of non-keyed associations, so cascading updates will not do.

How to store and manage a sql schema, with the ability to update and insert data

I am wondering what the best way (or any way) to manage a database schema. I have a sql file with a bunch of statements like CREATE TABLE Users { id SERIAL PRIMARY KEY ....}; which represents the schema for my database.
I have postgres installed on my dev machine however am having trouble syncing the changes I make to the schema with the local database. Currently I just run drop the entire database and run the schema file on the database.
I figure there has to be a better way I don't know about. I will also need to be able to set a database up for production when the project becomes more stabilized and obviously dropping a table in production wont work.
Suggestions?

Refreshing Oracle database tables after initial copy is made

I have a production and development database (on different systems of course). Many months ago, I copied the production database to the development system. I used exp/imp at the time. Since then there has been quite a few changes in the production database I would like to copy down to the development database. I'd rather not wipe out the development database and start over because of data I've had to add to the development database.
My original thought was to use MERGE INTO to copy the new records. But this apparently requires me to do this for tables, and list all fields of all tables. We're talking hundreds of tables and thousands of fields here. Not a pretty solution.
Is there an easier way?
Why not use the TABLE_EXISTS parameter of impdp to append the new data to the existing tables? Duplicate keys will error off but the rest of the data should still import. The results will be a bit messy. Prior to running TRUNCATE any tables in test where you can just bring the entire production table. Disable FK. Re-enable after import.
- -
Another option create a database link and generate INSERT/SELECT into all tables where data not in existing test table. You probably also want to disable FK prior to running and re-enable when done.

Merging multiple identical access database

I have started working on an existing frontend MS Access application built with VBA. It is linked to a backend Access database. So basically there are two Access databases - one frontend and one backend.
Because of the nature of the work involving vehicles, each user has their own copy of identical database with their individual data stored in backend. Constant Access to one backend db via internet is not really possible as the users are able to connect to internet (network) once a day only. Right now we just copy each backend database via ftp and store it as usr_backenddb_date.accdb
Backend databases contain around 16 tables with most of them containing an autonumber field as a primary key. Further tables are connected with each other referencing the primary key as a foreign key. I would ideally like to create a function in vba that lets me select the database and merge all the data from that database to an identical central database. For the initial part, I am thinking of doing something like this How to merge two identical database data to one? with possibly trying to cascade the change in autonumber field so the references remain intact.
I wanted to know if this approach is doable or if anyone has any other ideas and suggestion that I can look into.

Merging same structure databases but keeping their existing data.

Currently I have 3 (same code base apps) with it's own databases and own unique data. Were moving towards doing multi tenancy in rails, after a couple of prototype testing we've decided to go for a shared tenancy. My only biggest problem is that, each databases have their own data with unique ids and etc. How would it be possible to merge them either via sql command/dump or rails script that way they will have their own account_id + keep all data integrity?
Absolutely doable. It depends on a lot of details.
Basically I would
Make a full backup of all three.
Prep each database to hold compatible data (no duplicates).
Select one to be the new master.
Dump the other two (data only).
Hack the dump, to make sure. Typical COPY statements in dumps are just fine.
Restore data from the two additional database on top of existing data in the master.
Make sure all sequences are set properly.
Run vaccumdb -fz master.