473,799 Members | 3,006 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SET INTEGRITY question

aj
DB2 v8 FP5 WSE LUW
Red Hat Linux 2.1AS

I'm like to add a new column to an existing table that will be
NOT NULL and have a WITH DEFAULT value.

The table has a huge assortment of triggers, views, FK's, and
stored procs against it, so I don't want to take the usual steps
of creating a new table with the same structure plus the new
column, then copying all the data over and renaming the table.
(I would have to identify all the dependencies, drop them, do
the copy+rename, then recreate them).

Can I just SET INTEGRITY OFF for the table, add the NOT NULL WITH
DEFAULT column, populate the column, then SET INTEGRITY ON?

Any advice appreciated.

aj
Nov 12 '05 #1
4 1621
aj wrote:
DB2 v8 FP5 WSE LUW
Red Hat Linux 2.1AS

I'm like to add a new column to an existing table that will be
NOT NULL and have a WITH DEFAULT value.

The table has a huge assortment of triggers, views, FK's, and
stored procs against it, so I don't want to take the usual steps
of creating a new table with the same structure plus the new
column, then copying all the data over and renaming the table.
(I would have to identify all the dependencies, drop them, do
the copy+rename, then recreate them).

Can I just SET INTEGRITY OFF for the table, add the NOT NULL WITH
DEFAULT column, populate the column, then SET INTEGRITY ON?

Any advice appreciated.

ALTER TABLE T ADD COLUMN c1 INT NOT NULL WITH DEFAULT;
.... done... no SET INTEGRITY, no going for coffee, no worries...
DB2 for LUW had online schema evolution for this scenario since it's
inception.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
aj
Well.......don' t I feel like an idiot. I guess I can do that
with a simple:
alter table x add column1 int not null default 0

I *think* I discovered at one point that I could not add NOT NULLness
or WITH DEFAULT to an *existing* column (correct me if I'm wrong), so
I assumed I would see the same thing when adding a new column...

Can someone set me straight here?

TIA

aj

aj wrote:
DB2 v8 FP5 WSE LUW
Red Hat Linux 2.1AS

I'm like to add a new column to an existing table that will be
NOT NULL and have a WITH DEFAULT value.

The table has a huge assortment of triggers, views, FK's, and
stored procs against it, so I don't want to take the usual steps
of creating a new table with the same structure plus the new
column, then copying all the data over and renaming the table.
(I would have to identify all the dependencies, drop them, do
the copy+rename, then recreate them).

Can I just SET INTEGRITY OFF for the table, add the NOT NULL WITH
DEFAULT column, populate the column, then SET INTEGRITY ON?

Any advice appreciated.

aj

Nov 12 '05 #3
aj wrote:
Well.......don' t I feel like an idiot. I guess I can do that
with a simple:
alter table x add column1 int not null default 0

I *think* I discovered at one point that I could not add NOT NULLness
or WITH DEFAULT to an *existing* column (correct me if I'm wrong), so
I assumed I would see the same thing when adding a new column...

Can someone set me straight here?

You are correct that you cannot ALTER nullability.
In V8.2 you can ADD/DROP/ALTER DEFAULT for existing columns directly.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #4
aj
Many thanks Serge. :)

aj

Serge Rielau wrote:
aj wrote:
Well.......don' t I feel like an idiot. I guess I can do that
with a simple:
alter table x add column1 int not null default 0

I *think* I discovered at one point that I could not add NOT NULLness
or WITH DEFAULT to an *existing* column (correct me if I'm wrong), so
I assumed I would see the same thing when adding a new column...

Can someone set me straight here?


You are correct that you cannot ALTER nullability.
In V8.2 you can ADD/DROP/ALTER DEFAULT for existing columns directly.

Cheers
Serge

Nov 12 '05 #5

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

Similar topics

3
2744
by: Rodney King | last post by:
Hi, I am supporting an application that was converted from ACCESS to SQL Server 2000. My question focuses on two particuliar tables. The parent table has 14000 rows while child table has over 9 million rows. Referential integrity is set up between the two tables. The parent table has a composite primary key of: CustomerId (int) LocationId (int) ProductId (int)
9
1438
by: obhayes | last post by:
Hi, I have two tables Table A and B, below with some dummy data... Table A (contains specific unique settings that can be requested) Id, SettingName 1, weight 2, length Table B (contains the setting values, here 3 values relate to weight
10
2626
by: Paulo Jan | last post by:
Hi all: Let's say I'm designing a database (Postgres 7.3) with a list of all email accounts in a certain server: CREATE TABLE emails ( clienteid INT4, direccion VARCHAR(512) PRIMARY KEY, login varchar(128) NOT NULL,
4
15839
by: maricel | last post by:
I have the following base table structure - DDL: CREATE TABLE "ADMINISTRATOR"."T1" ( "C1" INTEGER NOT NULL ) IN "TEST_TS" ; ALTER TABLE "ADMINISTRATOR"."T1" ADD PRIMARY KEY
2
9987
by: Brice | last post by:
Hello, Sorry if this is a basic question but I can't seem to find the answer in the DB2 tutorial series or my DB2 manuals. How does one check the data integrity and referential integrity of an instance before running a backup? I see how one can run "db2ckbkp" after the backup has run, and I've seen some discussion of checksums in past postings, but what I'm looking for is more of: #!/bin/sh
1
3690
by: Grant McLean | last post by:
Hi First a simple question ... I have a table "access_log" that has foreign keys "app_id" and "app_user_id" that reference the "application_type" and "app_user" tables. When I insert into "access_log", the referential integrity triggers generate these queries: SELECT 1 FROM ONLY "public"."application_type" x
80
7903
by: Andrew R | last post by:
Hi I'm creating a series of forms, each with with around 15-20 text boxes. The text boxes will show data from tables, but are unbound to make them more flexible. I want the form to be used for both adding new data and modifying existing data. I have created a save button on the form. When the user clicks the save button, the code checks to see if there
16
5670
by: Brian Tkatch | last post by:
Is there a way to check the order in which SET INTEGRITY needs to be applied? This would be for a script with a dynamic list of TABLEs. B.
0
1919
by: WTH | last post by:
I ask because I've got a windows service I've written that manages failover and replication for our products (or even 3rd party applications) and it worked great right until I tested it (for ease of testing purposes) with Internet Explorer (iexplore.exe) - I was testing handling argument list buffer overflows. What I found with iexplore.exe is that because my windows service is running with high privileges (due to running under the local...
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10268
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10247
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10031
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9079
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7571
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.