Postgres CREATE TABLE AS SELECT with unknown column type

casting, create-table, postgresql, types

Solution

You need to explicitly cast your column, like this:

'0.0.0.0'::INET as IP,

Problem

I want to create a table with the following query: ``` create table something as select other_id, other_title, '0.0.0.0' as IP, 1 as used from other_table ``` But Postgres complains that: ``` column "ip" has type "unknown" ``` How can I specify it to be of type `char`?

Original source