易截截图软件、单文件、免安装、纯绿色、仅160KB

Virtual Columns in Oracle Database 11g

When queried, virtual columns appear to be normal table columns, but
their values are derived rather than being stored on disc. The syntax
for defining a virtual column is listed below.
column_name [datatype] [GENERATED ALWAYS] AS (expression) [VIRTUAL]
If the datatype is omitted, it is determined based on the result of the expression. The GENERATED ALWAYS
and VIRTUAL
keywords are provided for clarity only.
The script below creates and populates an employees table with two
levels of commission. It includes two virtual columns to display the
commission-based salary. The first uses the most abbreviated syntax
while the second uses the most verbose form.
CREATE TABLE employees (
id NUMBER,
first_name VARCHAR2(10),
last_name VARCHAR2(10),
salary NUMBER(9,2),
comm1 NUMBER(3),
comm2 NUMBER(3),
salary1 AS (ROUND(salary*(1+comm1/100),2)),
salary2 NUMBER GENERATED ALWAYS AS (ROUND(salary*(1+comm2/100),2)) VIRTUAL,
CONSTRAINT employees_pk PRIMARY KEY (id)
);
INSERT INTO employees (id, first_name, last_name, salary, comm1, comm2)
VALUES (1, 'JOHN', 'DOE', 100, 5, 10);
INSERT INTO employees (id, first_name, last_name, salary, comm1, comm2)
VALUES (2, 'JAYNE', 'DOE', 200, 10, 20);
COMMIT;
Querying the table shows the inserted data plus the derived commission-based salaries.
SELECT * from employees;
ID FIRST_NAME LAST_NAME SALARY COMM1 COMM2 SALARY1 SALARY2
---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
1 JOHN DOE 100 5 10 105 110
2 JAYNE DOE 200 10 20 220 240
2 rows selected.
SQL>
The expression used to generate the virtual column is listed in the DATA_DEFAULT
column of the [DBA|ALL|USER]_TAB_COLUMNS
views.
COLUMN data_default FORMAT A50
SELECT column_name, data_default
from user_tab_columns


相关文档:

北京亿阳信通Oracle笔试题

 
一、选择题
  
  1.当你执行以下查询语句:
  SELECT empno,ename
  from emp
  WHERE empno =7782 OR empno =7876;
  在WHERE语句中,以下哪个操作符可以取代OR?
  A. IN
  B. BETWEEN ……
  C. LIKE
  D. <=
  E. >=
  
  2. 哪个实现  ......

对Oracle学习者的一些建议

学习Oracle是一个漫长艰
辛的过程。如果没有兴趣,只是被迫学习,那么是很难学好的。学习到一定程度的时候,要想进一步提高,就不得不接触很多Oracle之外的东西,如
Unix,如网络、存储等。因此,要真的决心学好Oracle,就一定要有兴趣。有了兴趣,就会一切变得简单快乐起来。简单总结一下,那就是:兴趣、学
习、实践。 ......

关于ORACLE数据库中权限和角色的探索

Oracle数据库是一种大型关系型的数据库,我们知道当使用一个数据库时,仅仅能够控制哪些人可以访问数据库,哪些人不能访问数据库是无法满足数据库访问控制的。DBA需要通过一种机制来限制用户可以做什么,不能做什么,这在Oracle中可以通过为用户设置权限来实现。权限就是用户可以执行某种操作的权利。而角色是为了方便DBA管 ......

Oracle 存储过程

 
create or replace procedure p   //有就替换,没有就创建
is
     cursor c is
         select * from emp for update;
begin
  for v_emp in c loop
      if (v_emp.deptno =10) then
 &nb ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号