Function Based Virtual Columns in Oracle 11 g Database
2013-01-23 07:51
447 查看
Oracle Database 11g introduced new feature – virtual column. Instead storing data, the virtual column is calculated based on an expression stored in data dictionary. Let’s assume you have a table that stores customer information. The customer names are stored in two separate columns – first_name and last_name. The database queries often need to return the customer’s full name. Instead of storing the full name into the database or having to type it each time, you can define a new virtual column that is calculated, based on an expression:
Create a Oracle Database Table with calculated virtual column:
Add a new calculated virtual column to an existing Oracle Database Table:
Some of the virtual column benefits include:
Automatic re-computation of derived columns for ad-hoc query tools.
Reduction in redundant disk space for columns that must be derived from other columns (e.g. a MONTH column that is derived from another DATE column).
Keep business logic in a single place.
Easier interval partitioning based on calculated columns.
You should keep in mind that:
virtual columns may not reference other virtual columns;
virtual columns only within the containing table. You cannot reference columns within other tables.
Oracle Database virtual columns has the nice side effect of assisting in streamlining partitioning. For example, assume that we have a table that is partitioned by year-month (i.e. 2007-07). With 11g virtual columns, instead of creating separate column, we can simply compute the partition key virtually, using a DATE column.
first_name || ' ' || last_name.
Create a Oracle Database Table with calculated virtual column:
CREATE TABLE customer( first_name VARCHAR2(32), last_name VARCHAR2(32), full_name AS (first_name || ' ' || last_name) );
Add a new calculated virtual column to an existing Oracle Database Table:
ALTER TABLE customer ADD full_name AS (first_name || ' ' || last_name)
Some of the virtual column benefits include:
Automatic re-computation of derived columns for ad-hoc query tools.
Reduction in redundant disk space for columns that must be derived from other columns (e.g. a MONTH column that is derived from another DATE column).
Keep business logic in a single place.
Easier interval partitioning based on calculated columns.
You should keep in mind that:
virtual columns may not reference other virtual columns;
virtual columns only within the containing table. You cannot reference columns within other tables.
Oracle Database virtual columns has the nice side effect of assisting in streamlining partitioning. For example, assume that we have a table that is partitioned by year-month (i.e. 2007-07). With 11g virtual columns, instead of creating separate column, we can simply compute the partition key virtually, using a DATE column.
相关文章推荐
- Virtual Columns in Oracle Database 11g
- Virtual Columns in Oracle Database 11g
- Oracle:Virtual Columns in Oracle Database 11g Release 1
- Two Security Models in Oracle EBS:Function Security + Role-Based Access Control
- C++ 11: lexical closure in lambda function, example 1
- Know How To Use ID_NULL Function To Search An Object In Oracle Forms
- MySQL 表分区 A PRIMARY KEY must include all columns in the table's partitioning function
- Oracle列自增实现(2)-Identity Columns in Oracle Database 12c Release 1 (12.1)
- Example of Get_File_Name Function in Oracle Forms
- js原型继承与多态 How to apply virtual function in javascript
- Create Data Block Based On From Clause Query In Oracle Forms
- [Oracle Mgmt]Use RMAN to Duplicate Database in the Same Host (Based on Windows Platform)
- [PowerShell Utils] Create a list of virtual machines based on configuration read from a CSV file in Hyper-V
- How to "enalbe mouse integration" and make screen display fully in Oracle VM VirtualBox in Ubuntu
- a missing vtable usually means the first non-inline virtual member function has no definition.
- non-virtual thunk for Virtual Function in multiple inheritance
- Administering IPMP In Oracle Solaris 11 推荐
- How to create Function/Procedure in Oracle?
- Creating a Stored Procedure or Function in an Oracle Database
- oracle11中ORA-12505, TNS:listener does not currently know of SID given in connect desc