Обсуждение: CREATE table1 FROM table2

Поиск
Список
Период
Сортировка

CREATE table1 FROM table2

От
Rado Petrik
Дата:
Hi, 

How I create table1 from other table2 . 

"cp table1 table2" 

Thanks. 

-- 
Rado Petrik <r.p@szm.sk>




Re: CREATE table1 FROM table2

От
Devrim GUNDUZ
Дата:
Hi,

On 17 Jun 2003, Rado Petrik wrote:

> How I create table1 from other table2 . 

CREATE TABLE table1 AS SELECT * FROM table2;

will work.

Regards,
-- 
Devrim GUNDUZ
devrim@gunduz.org                devrim.gunduz@linux.org.tr         http://www.tdmsoft.com
http://www.gunduz.org



Re: CREATE table1 FROM table2

От
Achilleus Mantzios
Дата:
On 17 Jun 2003, Rado Petrik wrote:

> Hi, 
> 
> How I create table1 from other table2 . 
> 
> "cp table1 table2" 

create table table2 as select * from table1;

> 
> Thanks. 
> 
> 

-- 
==================================================================
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel:    +30-210-8981112
fax:    +30-210-8981877
email:  achill at matrix dot gatewaynet dot com       mantzios at softlab dot ece dot ntua dot gr



Re: CREATE table1 FROM table2

От
"Nicolas JOUANIN"
Дата:
Hi,

Documentation says:

CREATE [ [ LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name [ (column_name [,
...] ) ]    AS query

example : create table table1 as select * from table2;


> -----Message d'origine-----
> De : pgsql-sql-owner@postgresql.org
> [mailto:pgsql-sql-owner@postgresql.org]De la part de Rado Petrik
> Envoyé : mardi 17 juin 2003 17:21
> À : pgsql-sql@postgresql.org
> Objet : [SQL] CREATE table1 FROM table2
>
>
> Hi,
>
> How I create table1 from other table2 .
>
> "cp table1 table2"
>
> Thanks.
>
> --
> Rado Petrik <r.p@szm.sk>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend



Re: CREATE table1 FROM table2

От
Tomasz Myrta
Дата:
Dnia 2003-06-17 17:20, Użytkownik Rado Petrik napisał:
> Hi, 
> 
> How I create table1 from other table2 . 
> 
> "cp table1 table2" 
create table2 as select * from table1;
It is described in Postgresql documentation SQL Commands -> "create table as"

Regards,
Tomasz Myrta



Re: CREATE table1 FROM table2

От
Guillaume LELARGE
Дата:
Hi,

Le Mardi 17 Juin 2003 20:46, Achilleus Mantzios a écrit :
> On 17 Jun 2003, Rado Petrik wrote:
> > How I create table1 from other table2 .
> >
> > "cp table1 table2"
>
> create table table2 as select * from table1;
>
Another way would be: select * into table2 from table1;

(See
http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=sql-selectinto.html).


--
Guillaume <!-- http://absfr.tuxfamily.org/ -->.


Re: CREATE table1 FROM table2

От
"L.V.Boldareva"
Дата:
Hello!

many people posted their answer to this simple question. however,
neither
CREATE TABLE AS
nor
SELECT INTO

do not take care about keys and triggers, etc.

The commands above only copy the structure of the table, and the data.
Are there any workarounds fr copying the table as a whole object?

thanks,
Mila


> Hi,

> On 17 Jun 2003, Rado Petrik wrote:

>> How I create table1 from other table2 . 

> CREATE TABLE table1 AS SELECT * FROM table2;

> will work.

> Regards,



Re: CREATE table1 FROM table2

От
"scott.marlowe"
Дата:
On Mon, 23 Jun 2003, L.V.Boldareva wrote:

> Hello!
> 
> many people posted their answer to this simple question. however,
> neither
> CREATE TABLE AS
> nor
> SELECT INTO
> 
> do not take care about keys and triggers, etc.
> 
> The commands above only copy the structure of the table, and the data.
> Are there any workarounds fr copying the table as a whole object?

You probably want to use pg_dump dbname -t tablename and edit the file 
thus created by hand to create a new table etc...