IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need to add 3 columns to a table


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sivatechdrive

Active User


Joined: 17 Oct 2004
Posts: 191
Location: hyderabad

PostPosted: Mon Sep 10, 2007 12:46 pm
Reply with quote

I need to add 3 columns to a table
(The properties of 3 fields are data type Char(15) and NOT NULL with default) and these are non-primary key fields.
Can we add 3 columns to a table using single alter statement. If yes, please give an example.

Thanks n Regards
prasad
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Mon Sep 10, 2007 12:50 pm
Reply with quote

Hi Prasad,

Yes we can
Please refer the fine manual for this

publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/r0000888.htm
Back to top
View user's profile Send private message
sivatechdrive

Active User


Joined: 17 Oct 2004
Posts: 191
Location: hyderabad

PostPosted: Mon Sep 10, 2007 7:15 pm
Reply with quote

hi All

When i try to add the 2nd column i am getting the meesage as below
How to add 2 columns in single Alter.

ALTER TABLE RBR01T
ADD COLUMN EMP1 CHAR(1) NOT NULL WITH DEFAULT
ADD COLUMN EMP2 CHAR(1) NOT NULL WITH DEFAULT;
---------+---------+---------+---------+---------+---------+
DSNT408I SQLCODE = -637, ERROR: DUPLICATE ADD KEYWORD


Thanks n Regards
Prasad
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Sep 10, 2007 9:33 pm
Reply with quote

sivatechdrive wrote:
hi All

When i try to add the 2nd column i am getting the meesage as below
How to add 2 columns in single Alter.

ALTER TABLE RBR01T
ADD COLUMN EMP1 CHAR(1) NOT NULL WITH DEFAULT
ADD COLUMN EMP2 CHAR(1) NOT NULL WITH DEFAULT;
---------+---------+---------+---------+---------+---------+
DSNT408I SQLCODE = -637, ERROR: DUPLICATE ADD KEYWORD


Thanks n Regards
Prasad


You can only add 1 column with each alter table. Three columns would require three alters.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Sep 10, 2007 9:54 pm
Reply with quote

[quote="Craq Giegerich]You can only add 1 column with each alter table. Three columns would require three alters.[/quote]That is what the error says, but that does not agree with the syntax provided by link above.....
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Sep 10, 2007 10:05 pm
Reply with quote

After checking with the BM version of DB2 UDB for z/OS V8 SQL Reference
Quote:
Notes:
(1) The same clause must not be specified more than once, except for the ALTER COLUMN clause, which can be specified more than once.
I guess that's what happens when you don't check out the notes carefully enough.....
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Remote Unload of CLOB Columns DB2 6
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top