PostgreSQL将JSON迁移到JSONB

PostgreSQL将JSON迁移到JSONB

问题描述:

在PostgreSQL 9.4中,合并了新的JSONB.

In postgresql 9.4 the new JSONB was incorporated.

在PostgreSQL 9.3的实时数据库中,我有一个JSON列.

On a live DB in postgresql 9.3 I have a JSON column.

我想将其迁移到JSONB.

I want to migrate it to JSONB.

假设我首先将数据库迁移到9.4(使用pg_upgrade).接下来我该怎么办?

Assuming I migrated the DB first to 9.4 (using pg_upgrade). What do I do next?

ALTER TABLE table_with_json
  ALTER COLUMN my_json
  SET DATA TYPE jsonb
  USING my_json::jsonb;