wil*_*map 3 postgresql comments indentation pgadmin
当我从复杂查询创建视图时,我需要保留我在SQL查询中添加的注释,以便更容易地返回到视图定义.在pgAdminIII中,当我创建一个视图然后查阅视图定义时,注释被删除并且缩进完全修改了......有没有办法改变这种行为?
查看创建:
CREATE OR REPLACE VIEW public.v_test AS
-- Count number of null lines within table 'test'
(SELECT * FROM public.test WHERE client IS NULL);
Run Code Online (Sandbox Code Playgroud)
创建后查看定义,如pgAdminIII中所示:
-- View: v_test
-- DROP VIEW v_test;
CREATE OR REPLACE VIEW v_test AS
SELECT test.gid,
test.client
FROM test
WHERE test.client IS NULL;
ALTER TABLE v_test
OWNER TO postgres;
Run Code Online (Sandbox Code Playgroud)
感谢帮助!
Postgres不会按原样存储视图定义,因此您无法以这种方式存储注释.使用comment命令:
create view my_view as select 1;
comment on view my_view is 'It is my view';
select obj_description('my_view'::regclass);
obj_description
-----------------
It is my view
(1 row)
Run Code Online (Sandbox Code Playgroud)
你可以在PgAdmin3中看到评论:
-- View: public.my_view
-- DROP VIEW public.my_view;
CREATE OR REPLACE VIEW public.my_view AS
SELECT 1;
ALTER TABLE public.my_view
OWNER TO postgres;
COMMENT ON VIEW public.my_view
IS 'it is my view';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1103 次 |
| 最近记录: |