473,394 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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-
Nov 12 '05 #1
3 1383
Jurgen Haan wrote:
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-

Direct mit ALTER TABLE. Neu in V8.2

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
Serge Rielau wrote:
Jurgen Haan wrote:
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-


Direct mit ALTER TABLE. Neu in V8.2


Ah. Vielen dank.

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

-R-
Nov 12 '05 #3
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-
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: db2group88 | last post by:
i would like to know when i create a table with identity column, should i used generated by default or generated as always. since when i create this table, i might copy some data from another table...
1
by: Robert Stearns | last post by:
I have two related questions. Why did I have to: SET INTEGRITY FOR is3.animals OFF; before doing: alter table is3.animals add column pseudo_id generated always as (coalesce(regnum,...
2
by: valerio | last post by:
Hi all, I've some problem to import data to DB2 using the db2move and db2look tools. Follow the problem : I have exported data from db2 v. 7 database on windows server, using the db2look and...
17
by: Darek | last post by:
Hi, I have a table, something similar to: create table my_table ( id char(32) not null primary key, num integer not null, code varchar(2) not null, name varchar(60) not null,
3
by: Jessard | last post by:
Hi all, Can anyone give me an example of how to change what code the designer will generate when creating a typed dataset using the VS wizard? I have been informed that this is possible but...
5
by: Veeru71 | last post by:
Given a table with an identity column (GENERATED BY DEFAULT AS IDENTITY), is there any way to get the last generated value by DB2 for the identity column? I can't use identity_val_local() as...
1
by: Manuel Jaen | last post by:
Hi everybody, I'm starting up with those generated columns of the DB2, but all the examples that I come up are simple, and as far as I've read the thing I want to do is not possible. Can someone...
3
by: tonialbrown | last post by:
I am having some problems with an update statement. The problem is the data comes from a list box lstDelFrom that the user selects for the required record that they are copying the data from. This...
4
by: Bernard Dhooghe | last post by:
Table definition: CREATE TABLE "SCHEMA1 "."X2" ( "C1" CHAR(20) NOT NULL , "C2" CHAR(10) NOT NULL , "C3" CHAR(30) NOT NULL GENERATED ALWAYS AS (C1|| C2) ) IN "USERSPACE1" ; -- DDL...
1
by: Frank Swarbrick | last post by:
We're trying to take advantage of the new ROW CHANGE TIMESTAMP option. Here is a simple table: CREATE TABLE "ACCTASGN"."NUMBER_STATUS" ( "STATUS_CODE" CHAR(1) NOT NULL , "STATUS_DESCRIPTION"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.