0

I am trying to create a temporary table in postgres by copying the column names and types from an existing table.

CREATE TEMPORARY TABLE temporary_table LIKE grades;

Typing the query into Postgre, it tells me about an error in LIKE. Is "Like" keyword not usable in Postgre or am I doing something wrong?

1
  • What's the error message? Commented May 31, 2018 at 7:21

1 Answer 1

4

You need to wrap the like statement in parentheses:

CREATE TEMPORARY TABLE temporary_table (LIKE grades);

If you want defaults or indexes included as well, you need to add that explicitly

CREATE TEMPORARY TABLE temporary_table 
    (LIKE grades INCLUDING INDEXES INCLUDING DEFAULTS);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.