473,396 Members | 1,861 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,396 software developers and data experts.

Alter Column

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
3 4116
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dylan Nicholson | last post by:
Seems that Oracle 9.2 (using MS ODBC driver) requires extra parentheses when adding multiple columns to a table: ALTER TABLE MyTable ADD (MyColumn1 VARCHAR(255), MyColumn2 VARCHAR(255)) vs ...
1
by: Lannsjo | last post by:
I need to change my primary key column type from smallint to int. I have tried: ALTER TABLE livegroup MODIFY id INT UNSIGNED NOT NULL AUTO_INCREMENT; But get an error message certainly since my...
1
by: Bruce | last post by:
Hi, I want to change the datatype of an existing column from char to varbinary. When I run the "Alter Table" statement, I get the following error message - Disallowed implicit conversion...
5
by: minjie | last post by:
Is it possible to run a simple script to alter a table column in Access database from an interger to a double? I have been writing C++ programs every time we need to upgrade (modify) the Access...
4
by: Jeff Kish | last post by:
Hi. I have a database I need to supply something (I'm assuming a t-sql script.. maybe something else is better) to update customer tables with. The operations include mostly changing varchar...
2
by: RamaKrishna Narla | last post by:
In MS SQL Server, I have the following tables with some data in it. create table table1 ( column1 varchar(32), column2 int not null, column10 varchar(255), ..... primary key (column1,...
7
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get...
1
by: vasilip | last post by:
I'm testing out db2 for a project I'm starting that requires proper xml support and I can't seem to get both xml and spatial data to work well in the same table. Once having created a table...
0
by: spatik | last post by:
Hi, I have a tableevent] with a columnevent_description] as ntext and default value ''. Now, I want to change the column type to nvarchar(max) using this script, alter table alter column ...
3
by: sparks | last post by:
several months ago I was trying to set the field size of text fields in a table and Lyle Fairfield was nice enought to post a way using alter column. it was surprising since it was ALTER COLUMN...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.