473,805 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dropping a column in DB2

sat
hi all!
I have a doubt regarding the dropping of a column.
As i've seen, we have an option like
"alter table <table namedrop column <column name>" in
oracle.
Do we have any method in db2 to drop a column?
Or is there any process for dropping a column in db2?
if so, please let me know.
Thanks in Advance,
sat.

Aug 17 '06 #1
8 7040
sat wrote:
hi all!
I have a doubt regarding the dropping of a column.
As i've seen, we have an option like
"alter table <table namedrop column <column name>" in
oracle.
Do we have any method in db2 to drop a column?
Or is there any process for dropping a column in db2?
if so, please let me know.
Yes, DB2 V9 supports that.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Aug 17 '06 #2
sat

Knut Stolze wrote:
sat wrote:
hi all!
I have a doubt regarding the dropping of a column.
As i've seen, we have an option like
"alter table <table namedrop column <column name>" in
oracle.
Do we have any method in db2 to drop a column?
Or is there any process for dropping a column in db2?
if so, please let me know.

Yes, DB2 V9 supports that.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Hi Knut Stolze!
As u said it works on db2 V9 but i am using db2 V8.2 so if
i need to drop column on that what i need to do?

Thanks in Advance,
sat.

Aug 17 '06 #3
In DB2 V8.2 the straight forward case is to:
RENAME the table
CREATE TABLE LIKE the renamed table
INSERT SELECT or LOAD from CURSOR
DROP the old table.

If you have complex dependencies (RI, functions, triggers), take a look
at my post on the ALTOBJ procedure in this forum:
http://www.gatago.com/comp/databases.../24027879.html

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Aug 17 '06 #4

Serge Rielau wrote:
In DB2 V8.2 the straight forward case is to:
RENAME the table
CREATE TABLE LIKE the renamed table
INSERT SELECT or LOAD from CURSOR
DROP the old table.

If you have complex dependencies (RI, functions, triggers), take a look
at my post on the ALTOBJ procedure in this forum:
http://www.gatago.com/comp/databases.../24027879.html
Do we need a certain fixpak level to run the example? I tried it on
fixpak 9, but get errors because systools tables are missing (?). If
fixpak 9 is sufficient, where can I find the definition of systools
tables

Thanx
/Lennart
>>>
[db2inst1@wb-03 ~/nobackup/ltjn/test_altobj]$ db2 "CALL
SYSPROC.ALTOBJ( 'VALIDATE','CRE ATE TABLE DB2INST1.T(C1 BIGINT, C3 DOUBLE
NOT NULL)',-1,?)"
SQL0443N Routine "SYSPROC.ALTOBJ " (specific name "ALTOBJ") has
returned an
error SQLSTATE with diagnostic text "SQL0204 Reason code or token:
DB2INST1.T(C1". SQLSTATE=38553
[db2inst1@wb-03 ~/nobackup/ltjn/test_altobj]$ db2 "select tabname from
syscat.tables where tabschema = 'SYSTOOLS'"

TABNAME

--------------------------------------------------------------------------------------------------------------------------------
HMON_ATM_INFO

HMON_COLLECTION

POLICY
3 record(s) selected.

Aug 18 '06 #5
This function was introduced in DB2 V8.2 (FP7).
Try running db2updv8

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Aug 18 '06 #6

Serge Rielau wrote:
This function was introduced in DB2 V8.2 (FP7).
Try running db2updv8
Thanks. Unfortenate that doesnt help. I still get the error:

[db2inst1@wb-03 ~/nobackup/ltjn/test_altobj]$ db2 "CALL
SYSPROC.ALTOBJ( 'VALIDATE','CRE ATE TABLE DB2INST1.T(C1 BIGINT, C3 DOUBLE
NOT NULL)',-1,?)"
SQL0443N Routine "SYSPROC.ALTOBJ " (specific name "ALTOBJ") has
returned an
error SQLSTATE with diagnostic text "SQL0204 Reason code or token:
DB2INST1.T(C1". SQLSTATE=38553

Anything else that needs to be done?
Below are steps taken to reproduce error:

[db2inst1@wb-03 ~/nobackup/ltjn/test_altobj]$ uname -a
Linux wb-03 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686
i686 i386 GNU/Linux

[db2inst1@wb-03 ~/nobackup/ltjn/test_altobj]$ db2level
DB21085I Instance "db2inst1" uses "32" bits and DB2 code release
"SQL08022"
with level identifier "03030106".
Informational tokens are "DB2 v8.1.0.89", "OD_14086", "MI00105_14086" ,
and
FixPak "9".
Product is installed at "/opt/IBM/db2/V8.1".

[db2inst1@wb-03 ~/nobackup/ltjn/test_altobj]$ db2updv8 -d tmp
DB2UPDV8 complete successfully for database 'tmp'.

[db2inst1@wb-03 ~/nobackup/ltjn/test_altobj]$ db2stop
2006-08-18 22.19.40 0 0 SQL1064N DB2STOP processing was
successful.
SQL1064N DB2STOP processing was successful.

[db2inst1@wb-03 ~/nobackup/ltjn/test_altobj]$ db2start
2006-08-18 22.19.45 0 0 SQL1063N DB2START processing was
successful.
SQL1063N DB2START processing was successful.
[db2inst1@wb-03 ~/nobackup/ltjn/test_altobj]$ db2 connect to tmp

Database Connection Information

Database server = DB2/LINUX 8.2.2
SQL authorization ID = DB2INST1
Local database alias = TMP

[db2inst1@wb-03 ~/nobackup/ltjn/test_altobj]$ cat def.ddl
DROP FUNCTION FOO;
DROP TABLE T;
CREATE TABLE T (
c1 INT NOT NULL GENERATED ALWAYS AS IDENTITY,
c2 FLOAT
);
INSERT INTO T (c2) VALUES 10, 20, 30, 40, 50, 60, 70;

DROP VIEW V;
CREATE VIEW V AS SELECT c1, c2 FROM T;

DROP TRIGGER Trg1;
CREATE TRIGGER Trg1
BEFORE INSERT ON T
REFERENCING NEW AS N
FOR EACH ROW
SET n.c2 = COALESCE(n.c2, 7);

CREATE FUNCTION FOO ()
RETURNS FLOAT
LANGUAGE SQL
READS SQL DATA
NO EXTERNAL ACTION
NOT DETERMINISTIC
RETURN
select c2 from (
select c2, rownumber() over () as x from T
) Y where x = 1 ;

[db2inst1@wb-03 ~/nobackup/ltjn/test_altobj]$ db2 -tf def.ddl
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.

[db2inst1@wb-03 ~/nobackup/ltjn/test_altobj]$ db2 "CALL
SYSPROC.ALTOBJ( 'VALIDATE','CRE ATE TABLE DB2INST1.T(C1 BIGINT, C3 DOUBLE
NOT NULL)',-1,?)"
SQL0443N Routine "SYSPROC.ALTOBJ " (specific name "ALTOBJ") has
returned an
error SQLSTATE with diagnostic text "SQL0204 Reason code or token:
DB2INST1.T(C1". SQLSTATE=38553
Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Aug 18 '06 #7
le*****@kommuni cera.umea.se wrote:
Serge Rielau wrote:
>This function was introduced in DB2 V8.2 (FP7).
Try running db2updv8

Thanks. Unfortenate that doesnt help. I still get the error:

[db2inst1@wb-03 ~/nobackup/ltjn/test_altobj]$ db2 "CALL
SYSPROC.ALTOBJ( 'VALIDATE','CRE ATE TABLE DB2INST1.T(C1 BIGINT, C3 DOUBLE
NOT NULL)',-1,?)"
SQL0443N Routine "SYSPROC.ALTOBJ " (specific name "ALTOBJ") has
returned an
error SQLSTATE with diagnostic text "SQL0204 Reason code or token:
DB2INST1.T(C1". SQLSTATE=38553
Actually this has nothing to do with SYSTOOLS.
It says it can't find the usertable. What is a bit odd is that it
includes the "(C1". Just out of curiosity: Add a space after T before (.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Aug 18 '06 #8

Serge Rielau wrote:
le*****@kommuni cera.umea.se wrote:
Serge Rielau wrote:
This function was introduced in DB2 V8.2 (FP7).
Try running db2updv8
Thanks. Unfortenate that doesnt help. I still get the error:

[db2inst1@wb-03 ~/nobackup/ltjn/test_altobj]$ db2 "CALL
SYSPROC.ALTOBJ( 'VALIDATE','CRE ATE TABLE DB2INST1.T(C1 BIGINT, C3 DOUBLE
NOT NULL)',-1,?)"
SQL0443N Routine "SYSPROC.ALTOBJ " (specific name "ALTOBJ") has
returned an
error SQLSTATE with diagnostic text "SQL0204 Reason code or token:
DB2INST1.T(C1". SQLSTATE=38553
Actually this has nothing to do with SYSTOOLS.
It says it can't find the usertable. What is a bit odd is that it
includes the "(C1". Just out of curiosity: Add a space after T before (.
Thanks again Serge. That did the trick
/Lennart

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Aug 19 '06 #9

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

Similar topics

6
4403
by: Thomas | last post by:
Hello, A while back I dropped a text column from a SQL Server 7 database roughly 3GB in size. I expected the size of the database to decrease by around 1GB, but no change occurred. After searching usenet, I discovered that SQL Server 7 has no way of reclaiming that space, but that there is some command that can be run in SQL Server 2000 that will reclaim it. I have since migrated this database to SQL Server 2000, and am now
4
4029
by: Kumar | last post by:
Need urgent help.... I wanted update one table which has a primary key and also has few dependents. I dropped Primary key before update sothat it won't affect the dependent tables. After dropping promary key, I could see many packages were invalid in syscat.packages (VALID column).
1
1431
by: tfs | last post by:
I am reading into a datagrid and can't seem to get the "execution time" column (the 3rd column) to move to the right. My problem is that the last character in the 2nd column is right up against the end of the column and the 3rd column is too close and confusing. So I was trying to move the data in the 3rd column over a few spaces. So I did the following:
2
1449
by: Christian Blackburn | last post by:
Hi Gang, I would like to be able to drag and drop documents onto my application and have them open immediately thereafter. Can somebody point me towards a KB article or example? I could find a lot of examples pertaining to dragging and dropping objects within a form, but nothing about dragging external documents over a form. Thanks in Advance, Christian Blackburn
12
2220
by: ckirby | last post by:
I've got a csv that I am trying to import into a SQL Server (2000) table through an adp (Access 2000). The form used gives the user the ability to browse for a file, then will import the file into a temp table for processing using this vba code: DoCmd.TransferText acImportDelim, , "tmpPaTimeClock2", Me!TimeFileName, False When I run the import through the code, the import is dropping any values less than one (apparently). I've got a...
7
4675
by: Ross Mallett | last post by:
I have to drop large numbers of test tables (> 200) fairly often. This operation seems to be very slow. Is there some way to speed up the process of dropping tables?
3
1962
by: geoffrobinson | last post by:
In Microsoft SQL Server, I have a documents table and a table which categorizes the documents, which we'll call categories. I tried running UPDATE statements on the categories table previously and I ran into a foreign key constraint. The error given was "UPDATE statement conflicted with COLUMN REFERENCE constraint FK..." So I got rid of the Foreign Key relationship, and tried running an UPDATE statement against the categories table...
0
1235
by: 675i76 | last post by:
We've been using a macro to import Excel spreadsheets into an access 2002 database. After 5 months of this we found an error on a report. It turns out that access is ignoring the last row and last column of the spreadsheet. If the spreadsheet has 12 columns and 1000 rows the table will have 11 columns and 998 rows of data (one row is converted to field names). This happens when using Transferspreadsheet in a macro and in VBA. The same...
3
2146
by: =?Utf-8?B?TG9nZ2Vy?= | last post by:
Help, I’m applying updates to a web application that used Web Form Designer Generated Code. I’m using Visual Studio 2003. For some reason lines keep dropping out of the code in the .aspx.vb code behind file. Here’s the 2 lines that keep dropping. I think since the 1st line drops where the m_oConn is being assigned with the connection string it is being dropped everywhere it is being used. This of course causes errors when the...
0
10614
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
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
10369
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
9186
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
7649
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
6876
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
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.