pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christoph Berg <myon@debian.org>
To: Subodh Kumar <subodh.kumar@epps-erp.com>
Cc: pgsql-admin@lists.postgresql.org
Subject: Re: creating table without columns
Date: Tue, 30 Oct 2018 14:00:09 +0100
Message-ID: <20181030130009.GA7596@msg.df7cb.de> (raw)
In-Reply-To: <CA+KMk93CwQBP8SMeu_wcGdrj_ZTLVQVDpL-zbCd2vdy0hfWYrw@mail.gmail.com>
References: <CA+KMk93CwQBP8SMeu_wcGdrj_ZTLVQVDpL-zbCd2vdy0hfWYrw@mail.gmail.com>

Re: Subodh Kumar 2018-10-30 <CA+KMk93CwQBP8SMeu_wcGdrj_ZTLVQVDpL-zbCd2vdy0hfWYrw@mail.gmail.com>
> Hello Everyone,
>            I have run below query it is created 'test' table without
> columns
>            but table row count is 2.
> please give me clarity about this, i thought it may give syntax error but
> not
> either it must have 2 rows data but both are not happened.
> 
> 
> with ins_test as (select 1 as srno
> union
> select 2)
> select into test from ins_test;

You missed "srno":

with ins_test as (select 1 as srno
union
select 2)
select srno into test from ins_test;
       ^^^^

You can also "select from tbl;" -- omitting the target list.

The easier way to get a table without columns, but with rows is this:

create table test();
insert into test default values;
insert into test default values;

Christoph




view thread (5+ messages)  latest in thread

Message-ID: <20181030130009.GA7596@msg.df7cb.de>
Permalink:  ../20181030130009.GA7596@msg.df7cb.de/
Also on:    postgresql.org/message-id/20181030130009.GA7596@msg.df7cb.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: myon@debian.org, subodh.kumar@epps-erp.com, pgsql-admin@lists.postgresql.org
  Subject: Re: creating table without columns
  In-Reply-To: <20181030130009.GA7596@msg.df7cb.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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