2011-09-16 45 views
0

“psql \ dt information_schema”我正在编写此命令以查看所有表及其询问的列表“”用户information_schema的密码:“”我应该提供哪个密码,I meadn I m提供postgres作为密码。Postgres sql列出数据库中的所有表格

+1

问问你的DBA ... – NPE

回答

3

你用下面的命令做什么:

psql \dt information_schema 

是启动PSQL并通过名为“INFORMATION_SCHEMA”作为用户名与连接。

必须输入\dt information_schema命令您已经启动psql并且您看到psql提示符后。

如果您想直接在命令行中运行,而无需等待psql的提示,则需要使用-c开关:

psql -c "\dt information_schema.*" postgres postgres 

所有参数和他们预计的排列顺序当您运行psql --help或看看手册:

http://www.postgresql.org/docs/current/static/app-psql.html

编辑

下面是一个简单的控制台会话将告诉您如何做到这一点:

 
c:\>psql postgres postgres 
Password for user postgres: 
psql (9.0.4) 
Type "help" for help. 

postgres=# \dt information_schema.* 
         List of relations 
     Schema  |   Name   | Type | Owner 
--------------------+-------------------------+-------+---------- 
information_schema | sql_features   | table | postgres 
information_schema | sql_implementation_info | table | postgres 
information_schema | sql_languages   | table | postgres 
information_schema | sql_packages   | table | postgres 
information_schema | sql_parts    | table | postgres 
information_schema | sql_sizing    | table | postgres 
information_schema | sql_sizing_profiles  | table | postgres 
(7 rows) 

postgres=# \dv information_schema.* 
          List of relations 
     Schema  |    Name    | Type | Owner 
--------------------+-----------------------------------+------+--------- 
information_schema | _pg_foreign_data_wrappers   | view | postgres 
information_schema | _pg_foreign_servers    | view | postgres 
information_schema | _pg_user_mappings     | view | postgres 
information_schema | administrable_role_authorizations | view | postgres 
information_schema | applicable_roles     | view | postgres 
information_schema | attributes      | view | postgres 
information_schema | check_constraint_routine_usage | view | postgres 
information_schema | check_constraints     | view | postgres 
information_schema | column_domain_usage    | view | postgres 
information_schema | column_privileges     | view | postgres 
information_schema | column_udt_usage     | view | postgres 
information_schema | columns       | view | postgres 
information_schema | constraint_column_usage   | view | postgres 
information_schema | constraint_table_usage   | view | postgres 
information_schema | data_type_privileges    | view | postgres 
information_schema | domain_constraints    | view | postgres 
information_schema | domain_udt_usage     | view | postgres 
-- More -- 

这里是如何做到这一点的一个电话:

 
c:\>psql -c "\dt information_schema.*" postgres postgres 
Password for user postgres: 
         List of relations 
     Schema  |   Name   | Type | Owner 
--------------------+-------------------------+-------+---------- 
information_schema | sql_features   | table | postgres 
information_schema | sql_implementation_info | table | postgres 
information_schema | sql_languages   | table | postgres 
information_schema | sql_packages   | table | postgres 
information_schema | sql_parts    | table | postgres 
information_schema | sql_sizing    | table | postgres 
information_schema | sql_sizing_profiles  | table | postgres 
(7 rows) 

c:\ 
相关问题