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
 

 

Detail example with explaination for ALTER command

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

New User


Joined: 02 Jul 2004
Posts: 4

PostPosted: Fri Jul 02, 2004 3:25 pm    Post subject: Detail example with explaination for ALTER command
Reply with quote

Hai Friends,

I am having doubt in db2 alter command.

can anyone give detail example with explaination for alter command.

that is alter table, alter column, alter constraints, drop constaints, drop column
Back to top
View user's profile Send private message

priya

Moderator


Joined: 24 Jul 2003
Posts: 568
Location: Bangalore

PostPosted: Sat Jul 03, 2004 12:21 am    Post subject: rE
Reply with quote

ALTER command is used to alter the parameters of STORAGE GROUP or TABLE, index and tablespace.
Back to top
View user's profile Send private message
krbabu

New User


Joined: 20 Feb 2004
Posts: 57

PostPosted: Mon Jul 05, 2004 1:07 pm    Post subject:
Reply with quote

Hi barani,
Alter command is used to alter the structure of the table, length of the colums and change the constraint.
Back to top
View user's profile Send private message
Bharani

New User


Joined: 02 Jul 2004
Posts: 4

PostPosted: Tue Jul 06, 2004 9:22 am    Post subject: DB2 - Alter
Reply with quote

Hai Friends

I need example query. please explain with example query for alter
Back to top
View user's profile Send private message
meetsrk

New User


Joined: 13 Jun 2004
Posts: 85

PostPosted: Tue Jul 06, 2004 9:35 pm    Post subject:
Reply with quote

hi bharani,

while using alter table in DB2 always keep these things in mind,

u cannot do the following,

#change not null --> null
#reduce the size of the field i.e char(20) to Char(10)
#drop a praticular column

a syntax to add a new column for size 10 fields.

Code:

alter table existing-table-name add new-column-name char(10)
Back to top
View user's profile Send private message
Bharani

New User


Joined: 02 Jul 2004
Posts: 4

PostPosted: Wed Jul 07, 2004 9:32 am    Post subject:
Reply with quote

[quote] Thank U Friend if u r giving more examples means i will be comfortable. then can we create sequence in db2 if we can means what is the syntax to create the sequence.
Quote:
Back to top
View user's profile Send private message
satya123
Warnings : 1

New User


Joined: 18 Aug 2006
Posts: 57

PostPosted: Sat Aug 19, 2006 12:50 pm    Post subject:
Reply with quote

u can increase the column size for varchar fields but not decrease
Back to top
View user's profile Send private message
mahsug

New User


Joined: 01 Jul 2003
Posts: 15
Location: Phoenix , AZ

PostPosted: Mon Aug 21, 2006 11:59 am    Post subject: Sequences
Reply with quote

Hi Bharani ,

Yes, you can create Sequences in Db2 , Below are the informations regarding the same .

To Create a Sequence

You need to have any one of the following :

| The CREATEIN privilege on the schema

| SYSADM or SYSCTRL authority

Command :

CREATE SEQUENCE ORDER_SEQ
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO CYCLE
CACHE 20;

Note :
1) You need to provide the starting value , and incrementing value , say here it is 1 , so every time you say next value , it will be incremented by 1
2) MAXVALUE : MaxVALUE is the maximum value for your sequence , if you say 25 , your sequence will range from 1 - 25
3) CYCLE : When your maxvalue is reached , this is to say whether you want to reuse the same sequence numbers , say if you say MAXVALUE is 10 and CYCLE YES , when your sequence reaches 10 and you call for the next value , the sequence will be resetted to the first value , ie 1 .

Using Sequence values with your DML Operations

INSERT INTO ORDERS (ORDERNO, CUSTNO)
VALUES (NEXT VALUE FOR ORDER_SEQ, 123456);

UPDATE ORDERS
SET ORDERNO = NEXT VALUE FOR ORDER_SEQ
WHERE ORDERNO = 123456;


Hope , I have cleared your doubt .

Bye ,
Mahesh
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 TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Customizing the ISPF HILITE Command Pedro TSO/ISPF 3 Fri Mar 03, 2017 11:49 pm
No new posts Fail to change physical VSAM filename... jacobdng CICS 7 Fri Jan 20, 2017 12:36 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm
No new posts SDSF Command Avtrix CLIST & REXX 4 Fri Sep 30, 2016 11:13 am


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