Re: Copy table structure

Поиск
Список
Период
Сортировка
Искать
От
Peter Childs
Тема
Re: Copy table structure
Дата
Msg-id
Pine.LNX.4.44.0310080826540.4936-100000@RedDragon.Childs
Ответ на
Re: Copy table structure (paul@entropia.co.uk)
Список
Дерево обсуждения
Copy table structure Anshuman Kanwar <ansh@expertcity.com>
Re: Copy table structure "Louise Cofield" <lcofield@box-works.com>
Re: Copy table structure paul@entropia.co.uk
Re: Copy table structure Peter Childs <blue.dragon@blueyonder.co.uk>
On Wed, 8 Oct 2003 paul@entropia.co.uk wrote:

> On 4 Oct 2003 at 12:22, Anshuman Kanwar wrote:
> 
> here's one way:
> 
> mfx=# begin; create table NEWTABLE as select * from OLDTABLE; delete from 
> NEWTABLE; end;

	Whats wrong with

CREATE TABLE newtable AS SELECT * FROM oldtable WHERE false;

The first method will mean having to vacuum the table after putting loads 
of data in and then removing it. Also WHERE false should be faster 
especially if oldtable is full of data.
	Using either method you will only get the column types not the 
constraints, primary keys, indexes, defaults, not null, etc. Which I guess 
is what you really want :(

Peter Childs

> 
> Hope this helps
> 
> Paul Butler
> 
> > Hi all,
> > 
> > How do I copy only the table structure from one tabe to another.
> > 
> > Table A has some data but I just want to copy the number of columns and the
> > column names from this table  and create a table B. What is the best way of
> > doing this ?
> > 
> > Thanks in advance,
> > -ansh
> > 
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: Have you searched our list archives?
> > 
> >                http://archives.postgresql.org
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
>                http://archives.postgresql.org
> 

В списке pgsql-novice по дате отправления
От: paul@entropia.co.uk
Дата:
Сообщение: Re: Copy table structure
От: Chris Boget
Дата:
Сообщение: Re: Copy table structure
FAQ