Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does PostgreSQL's \dt show only public schema tables?

Tags:

postgresql

I have created a new schema in my PostgreSQl database with psql:

CREATE SCHEMA my_schema; 

But when I issue the \dt command, I see only the tables that are in the public schema. However, I can access all the tables in my_schema with my_schema.table_name.

How can I see all the tables from all the schemas in psql?

like image 924
skanatek Avatar asked Aug 03 '11 19:08

skanatek


People also ask

Is public default schema in PostgreSQL?

In PostgreSQL, by default, every database owns a default Schema named public. If you do not mention schema_name while creating or accessing the object then PostgreSQL will consider the schema_name as public.

What is public schema in PostgreSQL?

Public schema and public roleWhen a new database is created, PostgreSQL by default creates a schema named public and grants access on this schema to a backend role named public . All new users and roles are by default granted this public role, and therefore can create objects in the public schema.

How do I connect to a specific schema in PostgreSQL?

How to Use Schema With PostgreSQL. To access an object of a database schema, we must specify the schema's name before the name of a given database object that we want to use. For example, to query table product within schema store, we need to use the qualified name of the table: SELECT * FROM store.


1 Answers

For your schema (note the period after the schema name):

\dt my_schema. 

Or:

SET search_path TO my_schema, public; \dt 

For all schemas:

\dt *. 
like image 195
Alex Howansky Avatar answered Oct 19 '22 08:10

Alex Howansky