0

Is there a way to import all sequences of a schema from a dump of a schema (generated with exp full=y)? I don't want to import procedures or tables, but only all the sequences.

I want to use the imp command.

APC
  • 144,005
  • 19
  • 170
  • 281
esoni
  • 1,362
  • 4
  • 24
  • 37
  • 1
    You could do this with datapump `expdp`/`impdp`, using the `include` parameter on [export](http://docs.oracle.com/cd/E11882_01/server.112/e22490/dp_export.htm#i1007837) or [import](http://docs.oracle.com/cd/E11882_01/server.112/e22490/dp_import.htm#autoId29), but not the old `exp`/`imp`. Is there a reason you're stuck using the old utilities? – Alex Poole Apr 22 '13 at 08:18

2 Answers2

3

If you use the original Import utility, you can use four different modes: Table Mode, User Mode, Full Database Mode, and Tablespace Mode.

Each of them will import different types of object, but they are not as controllable as the new Data Pump Import, and you cannot choose exactly which types to import.

See the documentation here.

Sequences are imported in User and Full Database modes, but that also imports many other object types, including procedural objects (procedures, functions and packages).

I think you will have to open the dmp file with a text editior and copy-paste the Create Sequence statements to a new .sql file. You may be able to use Perl, Ruby, or a shell script to make that easier, but you cannot do it with imp only.

David Aldridge
  • 51,479
  • 8
  • 68
  • 96
3

exp has it's limitations. expdp is the better option if you want to use an exp/imp like solutiuon.

If the goal is to just copy the sequences, why not use dbms_metadata to get the ddl:

SELECT DBMS_METADATA.GET_DDL('SEQUENCE', u.sequence_name, decode(u.sequence_owner,'SYS','',sequence_owner)) ddl
     FROM all_sequences u where sequence_owner = 'SOE' order by sequence_owner, sequence_name;