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 4 1595
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
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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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,...
|
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
|
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...
|
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...
|
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...
|
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.
|
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...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |