pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedSQL command Error: "create table ... Like parentTable including defaults"
3+ messages / 3 participants
[nested] [flat]
* SQL command Error: "create table ... Like parentTable including defaults"
@ 2005-05-27 15:48 Ying Lu <ying_lu@cs.concordia.ca>
0 siblings, 2 replies; 3+ messages in thread
From: Ying Lu @ 2005-05-27 15:48 UTC (permalink / raw)
To: pgsql-sql
Greetings,
I have a simple question about SQL command :
create table tableName1 LIKE parentTable INCLUDING defaults ;
I was trying to create table "tableName1" with the same structure as
"parentTable" without any data. I got a syntax error:
'syntax error at or near "like" ... '
I guess there must be something wrong with my sql command, could
somebody help?
Thanks a lot,
Emi
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: SQL command Error: "create table ... Like parentTable
@ 2005-05-27 16:02 Bricklen Anderson <BAnderson@PresiNET.com>
parent: Ying Lu <ying_lu@cs.concordia.ca>
1 sibling, 0 replies; 3+ messages in thread
From: Bricklen Anderson @ 2005-05-27 16:02 UTC (permalink / raw)
To: Ying Lu <ying_lu@cs.concordia.ca>; +Cc: pgsql-sql
Ying Lu wrote:
> Greetings,
>
> I have a simple question about SQL command :
>
> create table tableName1 LIKE parentTable INCLUDING defaults ;
>
>
> I was trying to create table "tableName1" with the same structure as
> "parentTable" without any data. I got a syntax error: 'syntax error at
> or near "like" ... '
>
> I guess there must be something wrong with my sql command, could
> somebody help?
>
> Thanks a lot,
> Emi
I've never used the "LIKE..INCLUDING" clause before so I can't comment on that,
but as an alternative, you could try a CTAS:
create table tableName1 as select * from parentTable where 1=0; (will not get
the rows, just the structure).
Cheers,
Bricklen
--
_______________________________
This e-mail may be privileged and/or confidential, and the sender does
not waive any related rights and obligations. Any distribution, use or
copying of this e-mail or the information it contains by other than an
intended recipient is unauthorized. If you received this e-mail in
error, please advise me (by return e-mail or otherwise) immediately.
_______________________________
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: SQL command Error: "create table ... Like parentTable including defaults"
@ 2005-05-27 16:17 Michael Fuhr <mike@fuhr.org>
parent: Ying Lu <ying_lu@cs.concordia.ca>
1 sibling, 0 replies; 3+ messages in thread
From: Michael Fuhr @ 2005-05-27 16:17 UTC (permalink / raw)
To: Ying Lu <ying_lu@cs.concordia.ca>; +Cc: pgsql-sql
On Fri, May 27, 2005 at 11:48:39AM -0400, Ying Lu wrote:
>
> create table tableName1 LIKE parentTable INCLUDING defaults ;
>
> I was trying to create table "tableName1" with the same structure as
> "parentTable" without any data. I got a syntax error:
> 'syntax error at or near "like" ... '
The CREATE TABLE documentation shows that LIKE should be in parentheses:
CREATE TABLE tableName1 (LIKE parentTable INCLUDING DEFAULTS);
http://www.postgresql.org/docs/8.0/interactive/sql-createtable.html
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-05-27 16:17 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-05-27 15:48 SQL command Error: "create table ... Like parentTable including defaults" Ying Lu <ying_lu@cs.concordia.ca>
2005-05-27 16:02 ` Re: SQL command Error: "create table ... Like parentTable Bricklen Anderson <BAnderson@PresiNET.com>
2005-05-27 16:17 ` Re: SQL command Error: "create table ... Like parentTable including defaults" Michael Fuhr <mike@fuhr.org>
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