开发者

Postgresql - CREATE TABLE SYNTAX ERROR USING LIKE -

I'm trying to create a temp table from a parent table:

This is the code that I execute with pgAdmin III (or by JDBC in Java):

CREATE TEMP TABLE table1_tmp LIKE table1 INCLUDING DEFAULTS;

And the error I received is:

[WARNING  ] CREATE TEMP TABLE table1_tmp LIKE table1 INCLUDING DEFAULTS
        ERROR:  syntax error at or near «LIKE»
        LÍNEA 1: CREATE TEMP TABLE table1_tmp LIKE table1 INCLUDING DE开发者_高级运维FAULTS
                                              ^

Reading postgresql 8.4 documentation, create tables using this, its very easy, but I don't understand where is the syntax problem.


You need to put the like in to parens like

CREATE TEMP TABLE table1_tmp ( LIKE table1 INCLUDING DEFAULTS ) ;

This is not obvious from the docs if you don't count parens 1:1


I'm not a Postgresql user but the manual say that there is ( ) around the like setence.

CREATE TEMP TABLE table1_tmp (LIKE table1 INCLUDING DEFAULTS);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜