查看表信息,可以看到summary表属于schema gaoqiang:
music=> \d
List of relations
Schema | Name | Type | Owner
----------+---------+-------+----------
gaoqiang | summary | table | gaoqiang
(1 row)
使用用户postgres登录music数据库,可以看到有一个表summry,属于模式public,这个表实际上是之前创建的,里面已经有数据了:
music=> \c music postgres
You are now connected to database "music" as user "postgres".
music=# \d
List of relations
Schema | Name | Type | Owner
--------+---------+-------+----------
public | summary | table | postgres
(1 row)
往新建的schema gaoqiang下的表summary中插入一条数据:
music=# \c music gaoqiang
You are now connected to database "music" as user "gaoqiang".
music=> insert into summary values(1,'GaoQiang');
INSERT 0 1
查看表内容:
music=> select * from summary;
id | name
----+----------
1 | GaoQiang
(1 row)
然后去public模式下的同名表summary中插入一条与刚才不同的数据:
使用postgres用户连接库:
music=> \c music postgres
You are now connected to database "music" as user "postgres".
插入数据(与刚才那条不同,便于区分):
music=# insert into summary values(2,'GaoQiang');
INSERT 0 1
查看模式postgres模式下的summary表内容:
music=# select * from summary;
id | info
----+------------------------------
1 | Eric Gao is a Oracle DBA
1 | Eric Gao is a PostgreSQL DBA
1 | Eric Gao is a AIX SA
1 | Eric Gao is a Linux SA
2 | GaoQiang
(5 rows)
使用postgre用户在postgres模式下查看gaoqiang模式的summary表:
music=# select * from gaoqiang.summary;
id | name
----+----------
1 | GaoQiang
(1 row)
使用postgre用户在postgres模式下对gaoqiang模式的表中插入数据:
music=# insert into gaoqiang.summary values(2,'GaoQiang is not 2');
INSERT 0 1
查看gaoqiang.summary的内容:
music=# select * from gaoqiang.summary;
id | name
----+-------------------
1 | GaoQiang
2 | GaoQiang is not 2
(2 rows)