Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to create computed field/column in a table
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
> >
>
![]() |
![]() |