Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need to add 3 columns to a table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
sivatechdrive

Active User


Joined: 17 Oct 2004
Posts: 190
Location: hyderabad

PostPosted: Mon Sep 10, 2007 12:46 pm    Post subject: Need to add 3 columns to a table
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: 1187
Location: Bangalore,India

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

Hi Prasad,

Yes we can
Please refer the fine manual for this

http://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: 190
Location: hyderabad

PostPosted: Mon Sep 10, 2007 7:15 pm    Post subject:
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    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Mon Sep 10, 2007 9:54 pm    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Mon Sep 10, 2007 10:05 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 18 Thu Jul 13, 2017 2:11 pm
No new posts unload data from table with lob columns farhad_evan DB2 1 Sat Apr 22, 2017 1:32 pm
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us