一、创建视图
drop view srv_kims_zt_tablename;--删除视图避免重复
--创建视图开始
create or replace view srv_kims_zt_tablename as
select
z.id as column1,
z.name as column2,
z.age as column3,
to_date(z.busidate,'yyyy-MM-dd hh24:mi:ss') AS column4,
f.class as column5
from zt_tablename z
--from databasename.zt_tablename z --如果是不同的库前面要加库名
inner join tablename1 f on f.fid = z.id
where f.publishstatus = '1' and f.enddate is null
and z.busidate > '20200904'
order by z.fundcode,z.busidate
with read only;--只读
--添加注释
comment on table srv_kims_zt_tablename is '某某视图';
comment on column srv_kims_zt_tablename.column1 is '编号';
comment on column srv_kims_zt_tablename.column2 is '姓名';
comment on column srv_kims_zt_tablename.column3 is '年龄';
comment on column srv_kims_zt_tablename.column4 is '日期';
comment on column srv_kims_zt_tablename.column5 is '班级';
二、使用视图
select * from srv_kims_zt_tablename;