From: | William Leite Araújo <william(dot)bh(at)gmail(dot)com> |
---|---|
To: | Andrus <eetasoft(at)online(dot)ee> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to clone a table so that primay and foreign keys remain |
Date: | 2006-11-24 13:32:09 |
Message-ID: | bc63ad820611240532l3e7d2bcdg767507df986ec190@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
http://www.alberton.info/postgresql_meta_info.html
2006/11/24, Andrus <eetasoft(at)online(dot)ee>:
>
> I need to clone a schema in a database programmatically.
> Using pg_dump.exe to dump chema in plain text, then rename old schema and
> after that
> use pg_restore.exe to restore schema is slow since I need to clone data
> only
> in some smaller tables.
> Most of tables should be cloned without data.
>
> To start this I think I need to clone all schema tables first.
>
> How to create copy of table so that primary keys and foreign keys
> relationships remain ?
>
> I tried
>
> CREATE TABLE clone AS SELECT * FROM original
>
> But this creates plain table.
>
> Any idea ?
> Or where to find sample (simpler that pgAdmin or pg_dump source code)
> which
> re-constructs statements to create primary and foreign keys ?
>
> Andrus.
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org/
>
--
William Leite Araújo
Analista de Banco de Dados - QualiConsulte
From | Date | Subject | |
---|---|---|---|
Next Message | Brandon Aiken | 2006-11-24 14:32:31 | Re: IN clause |
Previous Message | sasan3 | 2006-11-24 12:44:08 | Carriage-Return in text field |