2011-09-16 75 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:\ 
相關問題