psql and schemas

Поиск
Список
Период
Сортировка
От Neil Conway
Тема psql and schemas
Дата
Msg-id 1099014906.21161.58.camel@localhost.localdomain
обсуждение исходный текст
Ответы Re: psql and schemas  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
psql's slash commands for schemas seem a little weird to me. For
example:

neilc=# \d nonexistent
Did not find any relation named "nonexistent".
neilc=# \dt nonexistent
No matching relations found.
neilc=# \dn nonexistent
List of schemasName | Owner 
------+-------
(0 rows)

-- Is there a good reason for this inconsistency?

neilc=# create schema foo_schema;
CREATE SCHEMA
neilc=# \dn foo_schema  List of schemas   Name    | Owner 
------------+-------foo_schema | neilc
(1 row)
neilc=# \dn foo_schema.     List of schemas       Name        | Owner 
--------------------+-------foo_schema         | neilcinformation_schema | neilcpg_catalog         | neilcpg_toast
    | neilcpublic             | neilc
 
(5 rows)

-- Why? (The same applies to "\dn nonexistent.")

neilc=# \d
No relations found.
neilc=# \d foo_schema.*
Did not find any relation named "foo_schema.*".

-- Why the difference in behavior? In any case, the error message is
confusing -- it suggests psql was looking for a relation with the name
"foo_schema.*", where it obviously was not:

neilc=# create table "foo_schema.*" (a int, b int);
CREATE TABLE
neilc=# \d foo_schema.*
Did not find any relation named "foo_schema.*".
neilc=# \d          List of relationsSchema |     Name     | Type  | Owner 
--------+--------------+-------+-------public | foo_schema.* | table | neilc
(1 row)

-- When you do \d schema.*, you get the definitions of _all_ the objects
in the schema. I can see why we support this, although I can't see it
being used very often. On the other hand, I think a much more common
case would be trying to get a list of all the objects in a schema -- is
there any way to do that? \dt schema.* lists the tables in a schema, for
example, but not the other types of objects (in a similar fashion to how
"\d" displays the objects in the search path).

That's all for now :-)

-Neil




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Christopher Kings-Lynne
Дата:
Сообщение: Re: pg_get_serial_sequence is inconsistent
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: Suggestion: additional system views