473,486 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

import/export or moving data between databases

Hello,

We a situation with a central database that contains the data that needs to be presented at N off-line terminals (N can be 5 000 can be 15 000). Each terminal presents unique data. The central database is used for data preparation. Then the data for each terminal is exported as separate SQL file. The terminals run the same application that is used to prepare the data - only in user mode. So what we do is - we export the full database structure (incl. triggers and stored procedures) - even if it contains some tables that are not needed at the terminal - this is not a big problem and it is easier to export all - and we export then N times the data for each terminal.

Then at the terminal we drop the old database, create new (this way we are sure that the database is 100% as it must be), import the structure and we import the terminal specific data. The transfer is always central database - > terminal database. There is no information sent back.

The problem we face is -

When we start to import - the triggers are executed - which must not happen. We found a way to turn the triggers off for the time of import and then turn them on after the import. However we can turn the triggers off only per table - so we need the list of tables, but we have not found a reliable way to get it. We can get them from the pg_ system tables - but this means if there is a change in them in next version - we need to change our software, which is not very desirable.

Has anybody similar experience with moving partial data from one database into another (with same database structure) - preserving absolutely everything about the data - IDs, etc. - that is done using only standard backend commands that are expected to survive over many versions of the database.

We use php 4/5 and we can execute shell commands if necessary.

Thank you everybody for the help.

Best,

Iavor

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #1
3 3964
"Iavor Raytchev" <po***@verysmall.org> writes:
The problem we face is - When we start to import - the triggers are executed - which must not happen. We found a way to turn the triggers off for the time of import and then turn them on after the import. However we can turn the triggers off only per table - so we need the list of tables, but we have not found a reliable way to get it. We can get them from the pg_ system tables - but this means if there is a change in them in next version - we need to change our software, which is not very desirable.


It sounds to me like you have reinvented pg_dump ... and not done it
very well. Why don't you just use pg_dump?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #2
Dear Tom,

We kind of read all documentation we could find, but that was the only way
we could get -

- export db structure into sql file
- export the records we need into another sql file
- import structure
- turn off triggers
- import the records
- turn on triggers

The main problem is that we export selected records - not the whole database
and not even whole tables. Also we export 5 000 to 15 000 such sets that
have small size - just a fraction of the size of the main database.

Can pg_dump help in that more than we use it?

Best,

Iavor

-----Original Message-----
From: Tom Lane [mailto:tg*@sss.pgh.pa.us]
Sent: Sunday, September 19, 2004 6:45 PM
To: Iavor Raytchev
Cc: pg***********@postgresql.org
Subject: Re: [GENERAL] import/export or moving data between databases
"Iavor Raytchev" <po***@verysmall.org> writes:
The problem we face is - When we start to import - the triggers are executed - which must not

happen. We found a way to turn the triggers off for the time of import and
then turn them on after the import. However we can turn the triggers off
only per table - so we need the list of tables, but we have not found a
reliable way to get it. We can get them from the pg_ system tables - but
this means if there is a change in them in next version - we need to change
our software, which is not very desirable.

It sounds to me like you have reinvented pg_dump ... and not done it
very well. Why don't you just use pg_dump?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #3
Iavor Raytchev wrote:
Dear Tom,

We kind of read all documentation we could find, but that was the only way
we could get -

- export db structure into sql file
- export the records we need into another sql file
- import structure
- turn off triggers
- import the records
- turn on triggers

The main problem is that we export selected records - not the whole database
and not even whole tables. Also we export 5 000 to 15 000 such sets that
have small size - just a fraction of the size of the main database.

Can pg_dump help in that more than we use it?

Why not select into temp tables as a new database then pg_dump the temp,
followed by restore of temp as though it were the whole thing?


Best,

Iavor

-----Original Message-----
From: Tom Lane [mailto:tg*@sss.pgh.pa.us]
Sent: Sunday, September 19, 2004 6:45 PM
To: Iavor Raytchev
Cc: pg***********@postgresql.org
Subject: Re: [GENERAL] import/export or moving data between databases
"Iavor Raytchev" <po***@verysmall.org> writes:
The problem we face is -


When we start to import - the triggers are executed - which must not


happen. We found a way to turn the triggers off for the time of import and
then turn them on after the import. However we can turn the triggers off
only per table - so we need the list of tables, but we have not found a
reliable way to get it. We can get them from the pg_ system tables - but
this means if there is a change in them in next version - we need to change
our software, which is not very desirable.

It sounds to me like you have reinvented pg_dump ... and not done it
very well. Why don't you just use pg_dump?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
9386
by: Benny | last post by:
Dear All, I am performing a data import on the SQL server. Due to fact that I use the excel file as a source. Some of cells in excel are actually empty, they become NULL fields after importing...
4
11344
by: TonyMontana | last post by:
Hello, I've the following problem. I've to read out the data of a custom application. I think (I'm not sure) this application is using a Paradox DB to store it's information. I don't know it...
4
12676
by: news | last post by:
Our production database in an exported textfil runs about 60 MB. Compressed that's about 9 MB. I'm trying to import the export into another machine running FC3 and mySQL 11.18, and it appears as...
5
3288
by: Kajol | last post by:
Hi All, can u plz tell me how to import data from mysql to another database. & how to export data from anotherdata base to mysql Thanx for ur Advice Regards Kajol
20
2733
by: Steve Jorgensen | last post by:
Hi all, I've just finished almost all of what has turned out to be a real bear of a project. It has to import data from a monthly spreadsheet export from another program, and convert that into...
4
3006
by: Steve Jorgensen | last post by:
I'm restarting this thread with a different focus. The project I'm working on now id coming along and will be made to work, and it's too late to start over with a new strategy. Still, I'm not...
7
33374
by: phillip.s.powell | last post by:
We're looking at a GUI interface for our MySQL DB and I am interested in MySQL Administrator, however, one of our requirements is to be able to import/export databases. Is this possible or do I...
10
11783
by: Niklas | last post by:
Hi Before I start coding I need to be sure that nobody else has not done it yet and that I can use it. I need an import utility which import data from Excel to a database or some object in...
7
4174
by: Randy | last post by:
Folks: We have a web-based app that's _really_ slowing down because multiple clients are writing their own private data into a single, central database. I guess the previous programmer did...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7319
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5430
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4864
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.