1

This statement is throwing syntax errors:

CREATE TABLE IF NOT EXISTS "weChat_data_abc" LIKE "weChat_data_sample"

The table weChat_data_sample exists and is empty.

I get the error:

Error : ERROR:  syntax error at or near "LIKE"

Output of SELECT VERSION():

PostgreSQL 9.4.4 on x86_64-apple-darwin14.4.0, compiled by Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn), 64-bit

1 Answer 1

1

Aha! I found the answer. Looks like I need to wrap the LIKE clause in parenthesis.

CREATE TABLE IF NOT EXISTS "weChat_data_abc"(LIKE "weChat_data_sample")

Documentation Here: http://www.postgresql.org/docs/9.4/static/sql-createtable.html

Sign up to request clarification or add additional context in comments.

4 Comments

Using quoted identifiers is almost always a bad choice. You should really avoid quoting identifiers, they are much more trouble in the long run than they are worth it
@a_horse_with_no_name I need quoted identifiers since my tables are written in semi camel case.
As I said: don't do that, it's really not worth all the trouble (and the typing)
@a_horse_with_no_name Can you give me an example of when this would be a problem?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.