Обсуждение: new table with a select

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

new table with a select

От
ppdcc@sapo.pt
Дата:

Hello to all,


Can anybody tell me the sql instruction to create a new table with a  
select of other table?

I need to create a new table based on paralell of a table of lines.  
Can anybody post to me a example?

Can?t be a buffer, must be lines.

Thanks








Re: new table with a select

От
Julien Cigar
Дата:
create table foo as select * from bar;

just add "where 1=2" if you just want the schema

On 08/25/2011 11:44, ppdcc@sapo.pt wrote:
>
>
> Hello to all,
>
>
> Can anybody tell me the sql instruction to create a new table with a
> select of other table?
>
> I need to create a new table based on paralell of a table of lines. Can
> anybody post to me a example?
>
> Can?t be a buffer, must be lines.
>
> Thanks
>
>
>
>
>
>
>


--
No trees were killed in the creation of this message.
However, many electrons were terribly inconvenienced.

Вложения

Re: new table with a select

От
Florian Weimer
Дата:
* Julien Cigar:

> create table foo as select * from bar;
>
> just add "where 1=2" if you just want the schema

There's also this:
 CREATE TABLE foo (LIKE bar);

This gives you more control over what aspects of the table are
duplicated; see the documentation for details.

--
Florian Weimer                <fweimer@bfk.de>
BFK edv-consulting GmbH       http://www.bfk.de/
Kriegsstraße 100              tel: +49-721-96201-1
D-76133 Karlsruhe             fax: +49-721-96201-99