Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generated column

Status
Not open for further replies.

ManuGenard

IS-IT--Management
Feb 26, 2004
2
GB
Hi,

Is there a way in Oracle to create a table with some of the columns automatically populated.
Let's say I have 3 amount columns and I want to the third to be the total of the 2 previous one.
I know I can use a trigger to do that, but my question is, is there a way to have that directly included in the table DDL just as in DB2 for example:
create table myTable (col1 integer, col2 integer, col3 GENERATED ALWAYS AS (col1+col2))

Anyone knows ??
 
I don't think so because that is considered bad database design to have a "derived column". If a column's value can be resolved from two other columns, you shouldn't keep in in most occaissions. Besides, what happens if one of the fields is updated?

Terry
**************************
* General Disclaimor - Please read *
**************************
Please make sure your post is in the CORRECT forum, has a descriptive title, gives as much detail to the problem as possible, and has examples of expected results. This will enable me and others to help you faster...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top