Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gHTd1-0000YH-W3 for pgsql-admin@arkaria.postgresql.org; Tue, 30 Oct 2018 13:00:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gHTd0-00012v-Az for pgsql-admin@arkaria.postgresql.org; Tue, 30 Oct 2018 13:00:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gHTd0-00012l-3f for pgsql-admin@lists.postgresql.org; Tue, 30 Oct 2018 13:00:14 +0000 Received: from feynman.df7cb.de ([195.49.152.168]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gHTcx-00068M-OS for pgsql-admin@lists.postgresql.org; Tue, 30 Oct 2018 13:00:13 +0000 Received: from msg.df7cb.de (unknown [IPv6:2003:5b:203b:100:7627:eaff:fe52:8e03]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by feynman.df7cb.de (Postfix) with ESMTPSA id 42ks562rkgz3Dww; Tue, 30 Oct 2018 14:00:10 +0100 (CET) Date: Tue, 30 Oct 2018 14:00:09 +0100 From: Christoph Berg To: Subodh Kumar Cc: pgsql-admin@lists.postgresql.org Subject: Re: creating table without columns Message-ID: <20181030130009.GA7596@msg.df7cb.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Re: Subodh Kumar 2018-10-30 > 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