pg_dump导出,psql导入:
[highgo@hg lib]$ ./pg_dump -h localhost -U highgo --port=5866 -f my_dump.sql --inserts
[highgo@hg lib]$ psql
psql (4.0.0)
Type "help" for help.
highgo=#
highgo=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+--------+----------+-------------+-------------+-------------------
highgo | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/highgo +
| | | | | highgo=CTc/highgo
template1 | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 | highgo=CTc/highgo+
| | | | | =c/highgo
test | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 | highgo=CTc/highgo+
| | | | | =Tc/highgo
(4 rows)
highgo=# drop database test;
DROP DATABASE
highgo=# create database test;
CREATE DATABASE
highgo=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+--------+----------+-------------+-------------+-------------------
highgo | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/highgo +
| | | | | highgo=CTc/highgo
template1 | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 | highgo=CTc/highgo+
| | | | | =c/highgo
test | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)
highgo=# \q
[highgo@hg lib]$ pwd
/highgo/hgdb4_server/lib
[highgo@hg lib]$ pg_restore -h localhost -p 5866 -U highgo -d test --create --verbose --format custom "/hig
[highgo@hg lib]$ ./pg_dump -h localhost -U highgo --port=5866 -f my_dump.sql --inserts
[highgo@hg lib]$ psql
psql (4.0.0)
Type "help" for help.
highgo=#
highgo=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+--------+----------+-------------+-------------+-------------------
highgo | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/highgo +
| | | | | highgo=CTc/highgo
template1 | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 | highgo=CTc/highgo+
| | | | | =c/highgo
test | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 | highgo=CTc/highgo+
| | | | | =Tc/highgo
(4 rows)
highgo=# drop database test;
DROP DATABASE
highgo=# create database test;
CREATE DATABASE
highgo=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+--------+----------+-------------+-------------+-------------------
highgo | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/highgo +
| | | | | highgo=CTc/highgo
template1 | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 | highgo=CTc/highgo+
| | | | | =c/highgo
test | highgo | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)
highgo=# \q
[highgo@hg lib]$ pwd
/highgo/hgdb4_server/lib
[highgo@hg lib]$ pg_restore -h localhost -p 5866 -U highgo -d test --create --verbose --format custom "/hig