View previous topic :: View next topic
|
Author |
Message |
sivatechdrive
Active User
Joined: 17 Oct 2004 Posts: 191 Location: hyderabad
|
|
|
|
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 |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
Back to top |
|
|
sivatechdrive
Active User
Joined: 17 Oct 2004 Posts: 191 Location: hyderabad
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
[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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
|