Need a command to insert columns in a table



IBM's flagship relational database management system

Need a command to insert columns in a table

Postby hakghen » Sat Nov 08, 2008 3:21 am

Hello friends,

I'm doing some tasks on a mainframe training, and I had to create the following table into the SPUFI:

CREATE TABLE ZCON039.EMPLOYEE
(EMPNO CHAR(6) NOT NULL,
FORENAME CHAR(20) NOT NULL,
INITIAL CHAR(1),
SURNAME VARCHAR(50) NOT NULL,
SEX CHAR(1) NOT NULL,
DOB DATE,
TELEPHONE CHAR(6),
DATE_HIRED DATE,
JOB CHAR(20),
SALARY DECIMAL(9,2),
BONUS DECIMAL(9,2),
COMMISSION DECIMAL(9,2),
DEPTNO CHAR(3),
LOCID CHAR(10),
PRIMARY KEY(EMPNO),
FOREIGN KEY (DEPTNO)
REFERENCES DEPARTMENT(DEPTNO) ON DELETE NO ACTION,
FOREIGN KEY (LOCID)
REFERENCES LOCATION(LOCID) ON DELETE NO ACTION)
IN SMDB039. SMTS039;


However, while creating, I forgot to insert the following columns: FORENAME, INITIAL and SURNAME. What is the command (or sql statement) that I should use now to insert these columns? I was thinking of trying the ALTER TABLE one, but I don't know if it will work.

[]'s, thanks in advance,

Andre
User avatar
hakghen
 
Posts: 59
Joined: Thu Sep 11, 2008 8:15 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need a command to insert columns in a table

 

Re: Need a command to insert columns in a table

Postby dick scherrer » Sat Nov 08, 2008 4:34 am

Hello,

Probably easiest to drop and re-create the table. Certainly more straight forward.

Then you will have a complete set of create syntax for use later rather than having your table definition fragmented. As it happens, tables do get dropped and re-created with some regularity.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Need a command to insert columns in a table

Postby hakghen » Sat Nov 08, 2008 4:41 am

Hmm... I see... Thanks Dick! :D
[]'s,

Hakghen
User avatar
hakghen
 
Posts: 59
Joined: Thu Sep 11, 2008 8:15 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need a command to insert columns in a table

Postby dick scherrer » Sat Nov 08, 2008 5:39 am

You're welcome - good luck :)

d
ps. if the table currently has data you want to preserve, unload the data first for later reload.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post