加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

oracle 给视图添加备注

(2013-05-17 11:35:53)
标签:

oracle

view

comment

分类: DataBase
Where there is love, I will be there.

参考示例:
--
create or replace view org_user_view as
select t.username,t.password from org_users;
comment on column org_user_view.username is '用户名;
comment on column org_user_view.password is '密码';

自己写的:
--
create or replace view v_material_stock as
with gift as
 (select c_id, c_name, c_materialposid
    from posjf_baseinfo
   where c_is_onshelves = '1'),
ins as
 (select initem.c_materialid, sum(i_num) as innum
    from posjf_in_storehouse ins, posjf_in_storehouse_item initem
   where ins.c_id = initem.c_id
     and ins.c_status = '0'
   group by initem.c_materialid),
outs as
 (select outitem.c_materialid, sum(i_num) as outnum
    from posjf_out_storehouse outs, posjf_out_storehouse_item outitem
   where outs.c_id = outitem.c_id
     and outs.c_status = '0'
   group by outitem.c_materialid),
waiting_outs as
(select shoporderitem.productid,sum(shoporderitem.quantity) as waitingoutnum
 from shop_order shoporder , shop_order_item shoporderitem
 where shoporder.pk = shoporderitem.orderpk
 and shoporder.orderstate = '1'
 group by shoporderitem.productid)
select g.c_id as baseinfoId,
       g.c_name as baseinfoname,
       g.c_materialposid as materialPosId,
       nvl(i.innum, 0) as innum,
       nvl(o.outnum, 0) as outnum,
       nvl(w.waitingoutnum,0) as waitingoutnum,
       (nvl(i.innum, 0) - nvl(o.outnum, 0) - nvl(w.waitingoutnum,0)) as available
  from gift g
  left join ins i
    on g.c_id = i.c_materialid
  left join outs o
    on g.c_id = o.c_materialid
  left join waiting_outs w
    on g.c_id = w.productid;
comment on column v_material_stock.innum is '累计入库';
comment on column v_material_stock.outnum is '累计出库';
comment on column v_material_stock.waitingoutnum is '已确认订单待出库';
comment on column v_material_stock.available is '可用库存';

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有