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

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 7028
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','CREATE 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','CREATE 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','CREATE 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*****@kommunicera.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','CREATE 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*****@kommunicera.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','CREATE 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
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...
4
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...
1
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...
2
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...
12
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...
7
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
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...
0
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...
3
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.