Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to create computed field/column in a table

Re: How to create computed field/column in a table

From: Richard B <someguyonthenet_at_hotmail.com>
Date: Tue, 20 Nov 2001 13:15:40 -0000
Message-ID: <3bfa5874@peer1.news.newnet.co.uk>


Hi Jesper,
 I don't know if Orcacle lets you have computed fields in a table definition. I don't believe that it does (but someone else might prove me wrong on this).

The only problem with this solution is that you have to do updates against the base table (mytable in our examples)

Good luck,

-Richard

"Jesper S. Knudsen" <jesper.stougaard.knudsen_at_omgroup.com> wrote in message news:u0qK7.214$%X5.3304821778_at_news.euroconnect.net...
> Hi Richard
>
> Thank you for your answer. But it has to be a computed field/column. Do
you
> know how?
>
> Gr.
>
> Jesper
>
> "Richard B" <someguyonthenet_at_hotmail.com> wrote in message
> news:3bfa4f8d_at_peer1.news.newnet.co.uk...
> >
> > "Jesper S. Knudsen" <jesper.stougaard.knudsen_at_omgroup.com> wrote in
> message
> > news:WxmK7.207$w04.3163937823_at_news.euroconnect.net...
> > > Hi
> > >
> > > Does anyone know how create a computed column in a table?
> > >
> > > In MS SQL Server you do it like this:
> > >
> > > CREATE TABLE mytable (
> > > key numeric not null primary key,
> > > value1 numeric not null,
> > > value2 numeric not null,
> > > value3 as (value1*value2)
> > > )
> > >
> > > How is it done in Oracle?
> > >
> > > Gr.
> > >
> > > Jesper
> > >
> > >
> >
> > The simplest way is to create a view against the table.
> > Eg.
> >
> > CREATE TABLE mytable (
> > value1 number not null,
> > value2 number not null);
> >
> > CREATE VIEW v_mytable as
> > SELECT value1, value2, (value1 * value2) as value3
> > FROM mytable;
> >
> >
> > The drawback with this method is that you can't update the value3 colum
> > directly. But presumably Transact-SQL wouldn't let you do this either.
> >
> >
> > -Richard
> >
>



> > ====
> >
> > "Propose to an Englishman any principle, or instrument, however
admirable,
> > and you will observe that the
> >
> > whole effect of the English mind is directed to find a difficulty, a
> defect,
> > or an impossibility in it.
> >
> > If you speak to him of a machine for peeling a potato, he will pronounce
> it
> > impossible;
> >
> > if you peel a potato with it before his eyes, he will declare it
useless,
> > because it will not slice a pineapple."
> >
> > -- Charles Babbage
> >
> >
>


> > ====
> >
> >
> >
>
>
Received on Tue Nov 20 2001 - 07:15:40 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US