pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to overwrite a table [only data]?
4+ messages / 4 participants
[nested] [flat]
* How to overwrite a table [only data]?
@ 2006-10-04 11:40 Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>
0 siblings, 3 replies; 4+ messages in thread
From: Ezequias Rodrigues da Rocha @ 2006-10-04 11:40 UTC (permalink / raw)
To: pgAdmin Support <pgadmin-support@postgresql.org>; pgsql-sql
Hi list,
I would like to overwrite a table with problem with his original. But there
are some points.
I can't just delete and restore it becouse it has a foreign key and when I
try to delete it ask for drop cascade.
As I know the drop cascade delete in both tables the rows related. Is it
correct ?
Regards...
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Atenciosamente (Sincerely)
Ezequias Rodrigues da Rocha
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
A pior das democracias ainda é melhor do que a melhor das ditaduras
The worst of democracies is still better than the better of dictatorships
http://ezequiasrocha.blogspot.com/
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: How to overwrite a table [only data]?
@ 2006-10-04 11:50 Harald Armin Massa <haraldarminmassa@gmail.com>
parent: Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>
2 siblings, 0 replies; 4+ messages in thread
From: Harald Armin Massa @ 2006-10-04 11:50 UTC (permalink / raw)
To: Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>; +Cc: pgAdmin Support <pgadmin-support@postgresql.org>; pgsql-sql
Ezequias ,
>
> I would like to overwrite a table with problem with his original. But
> there are some points.
>
> I can't just delete and restore it becouse it has a foreign key and when I
> try to delete it ask for drop cascade.
>
> As I know the drop cascade delete in both tables the rows related. Is it
> correct ?
>
> You are right.
Your database structure disallows this kind of deletes.
So, if you want to allow it, you have to disable / remove that foreign key
restriction, refresh your data, and reimplement that restriction.
Be aware that foreign key restrictions usually are there for a reason.
Harald
--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Reinsburgstraße 202b
70197 Stuttgart
0173/9409607
-
Python: the only language with more web frameworks than keywords.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] How to overwrite a table [only data]?
@ 2006-10-04 14:55 Aaron Bono <postgresql@aranya.com>
parent: Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>
2 siblings, 0 replies; 4+ messages in thread
From: Aaron Bono @ 2006-10-04 14:55 UTC (permalink / raw)
To: Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>; +Cc: pgAdmin Support <pgadmin-support@postgresql.org>; pgsql-sql
On 10/4/06, Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com> wrote:
>
> Hi list,
>
> I would like to overwrite a table with problem with his original. But
> there are some points.
>
> I can't just delete and restore it becouse it has a foreign key and when I
> try to delete it ask for drop cascade.
>
> As I know the drop cascade delete in both tables the rows related. Is it
> correct ?
You can drop the foreign keys and then the table. Then when you recreate
and repopulate the table, you can add the foreign keys back at the very end.
==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.com
http://codeelixir.com
==================================================================
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] How to overwrite a table [only data]?
@ 2006-10-04 16:49 Markus Schaber <schabi@logix-tt.com>
parent: Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>
2 siblings, 0 replies; 4+ messages in thread
From: Markus Schaber @ 2006-10-04 16:49 UTC (permalink / raw)
To: Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>; +Cc: pgAdmin Support <pgadmin-support@postgresql.org>; pgsql-sql
Hi, Ezequias,
Ezequias Rodrigues da Rocha wrote:
> I would like to overwrite a table with problem with his original. But
> there are some points.
>
> I can't just delete and restore it becouse it has a foreign key and
> when I try to delete it ask for drop cascade.
As long as the delete and restore is in the same transaction, SET
CONSTRAINTS ALL DEFERRED might help.
See the docs for more info.
> As I know the drop cascade delete in both tables the rows related. Is
> it correct ?
Yes, cascade will delete all referencing rows in the otehr table to keep
the constraints intact, keeping only those rows that have NULL in the
foreign key. I think that's not exactly what you want.
HTH,
Markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS
Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2006-10-04 16:49 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-10-04 11:40 How to overwrite a table [only data]? Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>
2006-10-04 11:50 ` Harald Armin Massa <haraldarminmassa@gmail.com>
2006-10-04 14:55 ` Aaron Bono <postgresql@aranya.com>
2006-10-04 16:49 ` Markus Schaber <schabi@logix-tt.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox