If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > finding all the identity column in DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-24-10, 08:18
kunal.gt kunal.gt is offline
Registered User
 
Join Date: Nov 2010
Posts: 2
finding all the identity column in DB2

how can we get all the existing identity and sequences in a database in DB2. we can use 2 different queries to find each one. Please help.
Reply With Quote
  #2 (permalink)  
Old 11-24-10, 10:02
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
have you tried UNION?
Reply With Quote
  #3 (permalink)  
Old 11-24-10, 10:10
kunal.gt kunal.gt is offline
Registered User
 
Join Date: Nov 2010
Posts: 2
SELECT TABNAME, COLNAME FROM SYSCAT.COLUMNS WHERE IDENTITY = 'Y'

The above query gives all the table name and column name which has column as identity..
Any way thanks for ur consideration..
Reply With Quote
  #4 (permalink)  
Old 11-24-10, 11:45
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
yes it does. Your other query gets the sequences I take it from your original mail. You want to run one query that gets them both at once and as I said try UNION

select cols from table1 where ....
UNION
select cols from table2 where...

Just ensure the columns match up with data type between the two queries.
Dave
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On