# Import Postgresql database

**URL:** <https://forum.yugabyte.com/t/import-postgresql-database/722>\
**Category:** General\
**Created:** [June 8, 2020, 11:51am UTC](https://forum.yugabyte.com/t/import-postgresql-database/722 "2020-06-08T11:51:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![puska](https://avatars.discourse-cdn.com/v4/letter/p/f17d59/32.png) [@puska](https://forum.yugabyte.com/u/puska)\
**Post date:** [June 8, 2020, 11:51am UTC](https://forum.yugabyte.com/t/import-postgresql-database/722/1 "2020-06-08T11:51:13Z")

</div>

Hi,

is there a way to export PostgreSQL 11 database and import it into YugaByteDB without manual intervention? I dumped PostgreSQL database using pg\_dump, but YugaByteDB does not support adding keys and indexes after a table is created (ALTER TABLE xxxx ADD CONSTRAINT). Since that is the way pg\_dump dumps a database it would make me edit resulting SQL file manualy or write a script to convert all CREATE TABLE commands to add constraints and than rearange the dump in order for dependencies to be satisfied.  
Is there a better way to do it?

---

<div class="post-metadata">

**Author:** ![dorian\_yugabyte](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/dorian_yugabyte/32/206_2.png) [@dorian\_yugabyte](https://forum.yugabyte.com/u/dorian_yugabyte)\
**Post date:** [June 8, 2020, 12:10pm UTC](https://forum.yugabyte.com/t/import-postgresql-database/722/2 "2020-06-08T12:10:31Z")

</div>

Hi @puska

Can you try first dumping just the schema and then just the data ?  
Having just the schema will make it easier to edit the file.

---

<div class="post-metadata">

**Author:** ![puska](https://avatars.discourse-cdn.com/v4/letter/p/f17d59/32.png) [@puska](https://forum.yugabyte.com/u/puska)\
**Post date:** [July 6, 2020, 9:19am UTC](https://forum.yugabyte.com/t/import-postgresql-database/722/3 "2020-07-06T09:19:35Z")

</div>

Hi,

I made a program to dump PostgreSQL schema and it works OK except for this issue:  
I have a column named order and when importing schema I am getting this error:

```
ERROR: syntax error at or near "order"
LINE 3: order integer ,

```

The table definition looks as:

```
CREATE TABLE public.main_insttoinst (
id integer DEFAULT nextval('main_insttoinst_id_seq'::regclass),
order integer ,
inst_id integer ,
spec_inst_id integer ,
CONSTRAINT main_insttoinst_inst_id_3774c8baec31686b_uniq UNIQUE (inst_id, spec_inst_id),
CONSTRAINT main_insttoinst_pkey PRIMARY KEY (id),
CONSTRAINT main_instt_spec_inst_id_5a3ce40b077534e7_fk_main_institution_id FOREIGN KEY (spec_inst_id) REFERENCES main_institution(id),
CONSTRAINT main_insttoinst_inst_id_229c6080da340d98_fk_main_institution_id FOREIGN KEY (inst_id) REFERENCES main_institution(id),
CONSTRAINT main_insttoinst_order_check CHECK (("order" >= 0))
);

```

Is that a parser bug (confusing order (column name) with ORDER BY)?

---

<div class="post-metadata">

**Author:** ![alex](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/alex/32/137_2.png) [@alex](https://forum.yugabyte.com/u/alex)\
**Post date:** [July 6, 2020, 10:41am UTC](https://forum.yugabyte.com/t/import-postgresql-database/722/4 "2020-07-06T10:41:39Z")

</div>

Hey @puska,

`ORDER` is a reserved word in SQL, and this is expected behavior. To use a reserved word as a column name, you’d have to double-quote it: `"order" integer`

---

<div class="post-metadata">

**Author:** ![puska](https://avatars.discourse-cdn.com/v4/letter/p/f17d59/32.png) [@puska](https://forum.yugabyte.com/u/puska)\
**Post date:** [July 7, 2020, 6:16am UTC](https://forum.yugabyte.com/t/import-postgresql-database/722/5 "2020-07-07T06:16:04Z")

</div>

Thanks, that worked out nicely.
