Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I was wondering how to use db2look to get the ddls of sequence.

db2look -d my_db_name -z my_proc_schema - I tried this but it is not showing any results.

Is there an option to directly mention the sequence name ?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You want to use the -e option. That will export sequences along with a few other things. Depending on your sequences you could either use the -z option for schema or the -a option for all schemas. You may also want to use the -o option to output to a file.

We tend to use the following a lot where I work

db2look -d my_db_name -e -o my_db_name_look.sql

EDIT: Based on the comments you have below, you can use db2look, or you could also use the system catalogs to retrieve what you need.

Why not run the following:

select seqschema,seqname from syscat.sequences where cycle = 'N'

That will retrieve those same sequences for you, but through querying and you won't have to use the db2look utility to retrieve everything you want. Of course if you want the DDL, you'd still have to use db2look to do that, but at least you can then use -z better to narrow down you schemas or do a search to find the names that came from your query.

share|improve this answer
    
-e exports everything from the db, isnt it ? @chris –  Govind Kailas Jul 22 '13 at 13:16
    
@Nachikethas - most everything. I find it doesnt't work for federated objects unless you use the -wrapper parm (and that before the -e one...). But according to the documentation -e will export sequence information. –  Chris Aldrich Jul 22 '13 at 19:16
    
-wrapper - What argument is it expecting ? –  Govind Kailas Jul 23 '13 at 10:51
    
I tried -e option, but it is exporting other objects like procedures which I don't wanted to get. @chris Any other thoughts ?? –  Govind Kailas Jul 23 '13 at 10:58
    
@Nachikethas - you don't have to worry about -wrapper unless you use federation (we do). Unfortunately there is no "just get only sequences" option. -e (everything), -u (only those objects created by a specified ID), -a (all objects including inoperative ones), or even -z (schema). No matter what way you try you will get more than your sequences. But that is ok. Just copy and paste out what you need. –  Chris Aldrich Jul 23 '13 at 12:53
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.