代码如下:

testdb=# create schema myschema1;
CREATE SCHEMA
testdb=# \d
          List of relations
 Schema |    Name    | Type  | Owner
--------+------------+-------+--------
 public | company    | table | kaiyin
 public | department | table | kaiyin
(2 rows)

testdb=#
testdb=# create table myschema1.company1(
testdb(#    ID   INT              NOT NULL,
testdb(#    NAME VARCHAR (20)     NOT NULL,
testdb(#    AGE  INT              NOT NULL,
testdb(#    ADDRESS  CHAR (25) ,
testdb(#    SALARY   DECIMAL (18, 2),
testdb(#    PRIMARY KEY (ID)
testdb(#    );
CREATE TABLE
testdb=# \d
          List of relations
 Schema |    Name    | Type  | Owner
--------+------------+-------+--------
 public | company    | table | kaiyin
 public | department | table | kaiyin
(2 rows)

testdb=# select * from myschema1.company1

什么也没出现。也许是因为桌子是空的?
testdb=# insert into myschema1.company1 values (1, joyce, 23, amsterdam, 60000, 1)
testdb-# select * from myschema1.company1
testdb-#

还是没什么。为什么?
苹果操作系统,postgresql 9.4.4

最佳答案

psql中的\d命令使用模式的当前搜索列表,默认情况下为public。你需要告诉它搜索你的模式:\d myschema1.*

10-07 12:34