在PostgreSQL中显示表(来自MySQL)的等价物是什么?


当前回答

select 
  * 
from 
  pg_catalog.pg_tables 
where 
  schemaname != 'information_schema' 
  and schemaname != 'pg_catalog';

其他回答

首次以postgres用户身份登录:sudo su-后期连接到所需的数据库:psql-d databaseName\dt将返回连接到的数据库中所有表的列表。

(MySQL)显示当前数据库的表列表

show tables;

(PostgreSQL)显示当前数据库的表列表

select * from pg_catalog.pg_tables where schemaname='public';

首先,您可以使用mac上的postgre.app或postico连接postgres数据库。运行以下命令:

psql -h localhost -p port_number -d database_name -U user_name -W

然后输入密码,这应该可以访问数据库

如果您只想查看已创建的表列表,可以只说:

\dt

但我们也有PATTERN,它将帮助您定制要显示的表。要显示包括pg_catalog架构在内的所有架构,可以添加*。

\时间*

如果您这样做:\?

\dt[S+][PATTERN]列表表

(为完整起见)

您还可以查询(SQL标准)信息架构:

SELECT
    table_schema || '.' || table_name
FROM
    information_schema.tables
WHERE
    table_type = 'BASE TABLE'
AND
    table_schema NOT IN ('pg_catalog', 'information_schema');