Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 10:45 AM
Jurgen Haan
Guest
 
Posts: n/a
Default generated column

Hi

Can I convert a plain integer column (non-key) in a table to a generated
column using the ALTER TABLE .. ALTER COLUMN statement?

If not, should I use the ALTOBJ statement?

-R-
  #2  
Old November 12th, 2005, 10:45 AM
Serge Rielau
Guest
 
Posts: n/a
Default Re: generated column

Jurgen Haan wrote:[color=blue]
> Hi
>
> Can I convert a plain integer column (non-key) in a table to a generated
> column using the ALTER TABLE .. ALTER COLUMN statement?
>
> If not, should I use the ALTOBJ statement?
>
> -R-[/color]
Direct mit ALTER TABLE. Neu in V8.2

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
  #3  
Old November 12th, 2005, 10:45 AM
Jurgen Haan
Guest
 
Posts: n/a
Default Re: generated column

Serge Rielau wrote:[color=blue]
> Jurgen Haan wrote:
>[color=green]
>> Hi
>>
>> Can I convert a plain integer column (non-key) in a table to a
>> generated column using the ALTER TABLE .. ALTER COLUMN statement?
>>
>> If not, should I use the ALTOBJ statement?
>>
>> -R-[/color]
>
> Direct mit ALTER TABLE. Neu in V8.2
>[/color]

Ah. Vielen dank.

I'm not German though (dutch) :P
(I DO understand the language)

-R-
  #4  
Old November 12th, 2005, 10:45 AM
Jurgen Haan
Guest
 
Posts: n/a
Default Re: generated column

Okay... I've defined a small test setup:
Created the following table
test (
bla1 integer,
bla2 integer,
);

inserted the following values: ((0,0),(0,1),(1,0),(1,1))

then I used the following statements:

set integrity for test off;
alter table test alter column BLA2 set generated always as (BLA1+2);
set integrity for test immediate checked force generated;

resulting in:

BLA1 BLA2
----------- -----------
0 2
0 2
1 3
1 3

Works like a charm :)

-R-
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,174 network members.