开发者

Postgresql - CREATE TABLE SYNTAX ERROR USING LIKE -

开发者 https://www.devze.com 2023-02-08 16:20 出处:网络
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):

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

精彩评论

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