postgresql中查看操作执行的具体sql语句
发布时间:2020-12-13 17:07:47 所属栏目:百科 来源:网络整理
导读:1)在psql启动命令行中加入-E例子:C:UsersAdministratorpsql -E -h localhost -p 5432 postgres postgrespsql (9.5.1)输入 "help" 来获取帮助信息.postgres=# d********* 查询 **********SELECT n.nspname as "Schema",c.relname as "Name",CASE c.relki
1)在psql启动命令行中加入-E 例子: C:UsersAdministrator>psql -E -h localhost -p 5432 postgres postgres psql (9.5.1) 输入 "help" 来获取帮助信息. postgres=# d ********* 查询 ********** SELECT n.nspname as "Schema",c.relname as "Name",CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'mate ialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'spe ial' WHEN 'f' THEN 'foreign table' END as "Type",pg_catalog.pg_get_userbyid(c.relowner) as "Owner" FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN ('r','v','m','S','f','') AND n.nspname <> 'pg_catalog' AND n.nspname <> 'information_schema' AND n.nspname !~ '^pg_toast' AND pg_catalog.pg_table_is_visible(c.oid) ORDER BY 1,2; ************************** 关联列表 架构模式 | 名称 | 类型 | 拥有者 ----------+------+--------+---------- public | test | 数据表 | postgres (1 行记录) 2)如果是已经进入的环境,想开启关闭: set ECHO_HIDDEN on|off 示例: C:UsersAdministrator>psql -h localhost -p 5432 postgres postgres psql (9.5.1) 输入 "help" 来获取帮助信息. postgres=# set ECHO_HIDDEN on postgres=# d ********* 查询 ********** SELECT n.nspname as "Schema",CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'mater ialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'spec ial' WHEN 'f' THEN 'foreign table' END as "Type",2; ************************** 关联列表 架构模式 | 名称 | 类型 | 拥有者 ----------+------+--------+---------- public | test | 数据表 | postgres (1 行记录) postgres=# set ECHO_HIDDEN off postgres=# d 关联列表 架构模式 | 名称 | 类型 | 拥有者 ----------+------+--------+---------- public | test | 数据表 | postgres (1 行记录) postgres=# (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |