Reputation: 482
After executing a pg_dump
from PostgeSQL, I attempted to import the .sql
file into CockroachDB, but received the following errors:
ERROR: unknown variable: "STATEMENT_TIMEOUT"
ERROR: unknown variable: "LOCK_TIMEOUT"
ERROR: unknown variable: "IDLE_IN_TRANSACTION_SESSION_TIMEOUT"
SET
SET
ERROR: unknown variable: "CHECK_FUNCTION_BODIES"
SET
ERROR: unknown variable: "ROW_SECURITY"
SET
ERROR: unknown variable: "DEFAULT_TABLESPACE"
ERROR: unknown variable: "DEFAULT_WITH_OIDS"
CREATE TABLE
ERROR: syntax error at or near "OWNER"
Any guidance?
Upvotes: 1
Views: 848
Reputation: 482
CockroachDB has special support for using psql
, which supports the COPY
command (which is faster than batched INSERT
statements).
You'll need to do two things:
After generating the .sql
file, you need to perform a few editing steps before importing it:
CREATE TABLE
and COPY
statements.Manually add the table's PRIMARY KEY
constraint to the CREATE TABLE
statement.
This has to be done manually because PostgreSQL attempts to add the primary key after creating the table, but CockroachDB requires the primary key be defined upon table creation.
After reformatting the file, you can import it through psql
:
$ psql -p [port] -h [node host] -d [database] -U [user] < [file name].sql
For reference, CockroachDB uses these defaults:
[port]
: 26257[user]
: rootUpvotes: 3