开发者

Oracle creating a table

How should we create a table which has a column as开发者_StackOverflow社区 the average of the totals present in previous columns? For ex :Departments (depno,depname,noofempl,totalsal,avgsal)

here value in avgsal must be (totalsal/noofempl)


If you are using Oracle 11 you might use virtual columns otherwise you can create a view that selects all your table columns and adds the average column

CREATE TABLE DEPARTMENTS
(
  DEPNO...
  DEPNAME...
  noofempl...
  totalsal...
);

CREATE VIEW VW_DEPARMENTS AS
SELECT DEPNO, DEPNAME, noofempl, totalsal, totalsal/noofempl as avgsal
FROM DEPARTMENTS;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜