By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,017 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,017 IT Pros & Developers. It's quick & easy.

Alter Column

P: n/a
Hi,

I'm trying to change a column on a DB2 table so that it has a default value
but I cannot get it to work. Does anyone have any experience in this area.

I'm trying with this statement:

Alter Table x
Alter column y default 0;

I also tried with this:

Alter Table x
Alter Column y Set Data Type SmallInt With Default 0;

And this:

Alter Table x
Alter Column y Set Default 0;

I simply cannot make it work ;o(

Thanks in advance

Kimi
Mar 31 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Kimi wrote:
Hi,

I'm trying to change a column on a DB2 table so that it has a default value
but I cannot get it to work. Does anyone have any experience in this area.

I'm trying with this statement:

Alter Table x
Alter column y default 0;

I also tried with this:

Alter Table x
Alter Column y Set Data Type SmallInt With Default 0;

And this:

Alter Table x
Alter Column y Set Default 0;

I simply cannot make it work ;o(

Which versiuon are you on?
DB2 V8.2 for LUW introduced altering of the default.
The syntax is described in the online books and in the latest (FP7)
local doc download.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Mar 31 '06 #2

P: n/a
It's DB2 V8.1 on z/OS ... as for the guides, I have a hard time
understanding what they're trying to describe ...

Thanks

Kimi

"Serge Rielau" <sr*****@ca.ibm.com> skrev i en meddelelse
news:49************@individual.net...
Kimi wrote:
Hi,

I'm trying to change a column on a DB2 table so that it has a default
value but I cannot get it to work. Does anyone have any experience in
this area.

I'm trying with this statement:

Alter Table x
Alter column y default 0;

I also tried with this:

Alter Table x
Alter Column y Set Data Type SmallInt With Default 0;

And this:

Alter Table x
Alter Column y Set Default 0;

I simply cannot make it work ;o(

Which versiuon are you on?
DB2 V8.2 for LUW introduced altering of the default.
The syntax is described in the online books and in the latest (FP7) local
doc download.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

Mar 31 '06 #3

P: n/a
Kimi wrote:
It's DB2 V8.1 on z/OS ... as for the guides, I have a hard time
understanding what they're trying to describe ...

Well, the syntax would be:
ALTER TABLE <tablename> ALTER COLUMN <columnname>
and then syntax to set/add or alter the default, but all you can do is
SET GENERATED [ALWAYS|DEFAULT].
Seems like you're out of luck w.r.t. to the straight approach.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Mar 31 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.