bash-4.1$ createdb epaydb
-bash-4.1$ psql epaydb
psql (9.4.3)
Type "help" for help.
epaydb=# create table test(a int);
CREATE TABLE
epaydb=# select * from test;
a
---
(0 rows)
epaydb=# \q
-bash-4.1$ psql epaydb2
epaydb2=# create table test2(a int);
CREATE TABLE
epaydb2=# insert into test2 values(a 1);
ERROR: syntax error at or near "1"
LINE 1: insert into test2 values(a 1);
^
epaydb2=# insert into test2 values(a ,1);
ERROR: column "a" does not exist
LINE 1: insert into test2 values(a ,1);
^
HINT: There is a column named "a" in table "test2", but it cannot be referenced from this part of the query.
epaydb2=# insert into test2(a) values(1);
INSERT 0 1
epaydb2=# insert into test2(a) values(2);
INSERT 0 1
epaydb2=# \q
-bash-4.1$ pg_dumpall > /var/lib/pgsql/epaydb22.dmp
-bash-4.1$ dropdb epaydb1
dropdb: database removal failed: ERROR: database "epaydb1" does not exist
-bash-4.1$ dropdb epaydb
-bash-4.1$ dropdb epaydb2
dropdb: database removal failed: ERROR: database "epaydb2" is being accessed by other users
DETAIL: There is 1 other session using the database.
-bash-4.1$ dropdb epaydb2
dropdb: database removal failed: ERROR: database "epaydb2" is being accessed by other users
DETAIL: There is 1 other session using the database.
-bash-4.1$ dropdb epaydb2
-bash-4.1$ psql -f /var/lib/pgsql/epaydb22.dmp postgres
SET
SET
SET
psql:/var/lib/pgsql/epaydb22.dmp:14: ERROR: role "epaysch" already exists
ALTER ROLE
psql:/var/lib/pgsql/epaydb22.dmp:16: ERROR: role "postgres" already exists
ALTER ROLE
psql:/var/lib/pgsql/epaydb22.dmp:28: ERROR: database "arch" already exists
psql:/var/lib/pgsql/epaydb22.dmp:29: ERROR: database "eapydb" already exists
CREATE DATABASE
CREATE DATABASE
psql:/var/lib/pgsql/epaydb22.dmp:32: ERROR: database "mydb" already exists
psql:/var/lib/pgsql/epaydb22.dmp:33: ERROR: database "pg" already exists
psql:/var/lib/pgsql/epaydb22.dmp:34: ERROR: database "pg1" already exists
psql:/var/lib/pgsql/epaydb22.dmp:35: ERROR: database "pg2" already exists
psql:/var/lib/pgsql/epaydb22.dmp:36: ERROR: database "postdb" already exists
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "arch" as user "postgres".
SET
SET
SET
SET
SET
SET
SET
CREATE EXTENSION
COMMENT
SET
SET
SET
psql:/var/lib/pgsql/epaydb22.dmp:84: ERROR: relation "test" already exists
ALTER TABLE
COPY 8
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "eapydb" as user "postgres".
SET
SET
SET
SET
SET
SET
SET
CREATE EXTENSION
COMMENT
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "epaydb" as user "postgres".
SET
SET
SET
SET
SET
SET
SET
CREATE EXTENSION
COMMENT
SET
SET
SET
CREATE TABLE
ALTER TABLE
COPY 0
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "epaydb2" as user "postgres".
SET
SET
SET
SET
SET
SET
SET
CREATE EXTENSION
COMMENT
SET
SET
SET
CREATE TABLE
ALTER TABLE
CREATE TABLE
ALTER TABLE
CREATE TABLE
ALTER TABLE
COPY 4
COPY 0
COPY 2
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "mydb" as user "postgres".
SET
SET
SET
SET
SET
SET
SET
psql:/var/lib/pgsql/epaydb22.dmp:361: ERROR: schema "myschema" already exists
ALTER SCHEMA
CREATE EXTENSION
COMMENT
SET
SET
SET
psql:/var/lib/pgsql/epaydb22.dmp:393: ERROR: relation "cities" already exists
ALTER TABLE
psql:/var/lib/pgsql/epaydb22.dmp:408: ERROR: relation "weather" already exists
ALTER TABLE
COPY 0
COPY 0
psql:/var/lib/pgsql/epaydb22.dmp:434: ERROR: multiple primary keys for table "cities" are not allowed
psql:/var/lib/pgsql/epaydb22.dmp:442: ERROR: constraint "weather_city_fkey" for relation "weather" already exists
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "pg" as user "postgres".
SET
SET
SET
SET
SET
SET
SET
CREATE EXTENSION
COMMENT
SET
SET
SET
psql:/var/lib/pgsql/epaydb22.dmp:500: ERROR: relation "pg_test" already exists
ALTER TABLE
COPY 8
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "pg1" as user "postgres".
SET
SET
SET
SET
SET
SET
SET
CREATE EXTENSION
COMMENT
SET
SET
SET
psql:/var/lib/pgsql/epaydb22.dmp:576: ERROR: relation "tb1" already exists
ALTER TABLE
COPY 2
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "pg2" as user "postgres".
SET
SET
SET
SET
SET
SET
SET
CREATE EXTENSION
COMMENT
SET
SET
SET
psql:/var/lib/pgsql/epaydb22.dmp:646: ERROR: relation "tb2" already exists
ALTER TABLE
COPY 2
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "postdb" as user "postgres".
SET
SET
SET
SET
SET
SET
SET
CREATE EXTENSION
COMMENT
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "postgres" as user "postgres".
SET
SET
SET
SET
SET
SET
SET
COMMENT
CREATE EXTENSION
COMMENT
SET
SET
SET
psql:/var/lib/pgsql/epaydb22.dmp:766: ERROR: relation "postgres_test" already exists
ALTER TABLE
COPY 8
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "template1" as user "postgres".
SET
SET
SET
SET
SET
SET
SET
COMMENT
CREATE EXTENSION
COMMENT
REVOKE
REVOKE
GRANT
GRANT
-bash-4.1$ psql epaydb
psql (9.4.3)
Type "help" for help.
epaydb=# select * from test;
a
---
(0 rows)
epaydb=# \q
-bash-4.1$ psql epaydb2
psql (9.4.3)
Type "help" for help.
epaydb2=# select * from test;
a
---
(0 rows)
epaydb2=# select * from test2;
a
---
1
2
(2 rows)
epaydb2=#
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29898569/viewspace-1718832/,如需转载,请注明出处,否则将追究法律责任。