Home » RDBMS Server » Server Administration » State of sequence in full db exp/imp
State of sequence in full db exp/imp [message #122967] Thu, 09 June 2005 07:00 Go to next message
mrinal.c
Messages: 2
Registered: June 2005
Junior Member
Hi Gurus,

If I'm importing a full database to an empty databse from a
*.dmp file(which is a full exp of a database),
then whether could I get the same sequences along with their current value
as that of I have in other database.

Example:

Db : A

It has a sequence seq1 with scott.seq1.currentval=15
where my sequence starts from 1 and ends at 40 with increment of 1.

Now I took : exp x/y file=say.dmp full=y

Db : B

imp x/y file=say.dmp constaraints=y indexes=y buffer=36000

Now my question is whether I'll get sequence scott.seq.currval=15 or not
????

Thanks in advance,

Wirh regards,
Mrinal
Re: State of sequence in full db exp/imp [message #122997 is a reply to message #122967] Thu, 09 June 2005 09:18 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
It depends on the CACHING of the sequence.
If you use NOCACHE, sequence numbers are not skipped.
scott@9i > create sequence mysequence1 start with 1 increment by 1 nocache;

Sequence created.

scott@9i > create table t1 (id number);

Table created.

scott@9i > create table t2 (id number);

Table created.

scott@9i > begin
  2  for mag in 1..12 loop
  3  insert into t1 values (mysequence1.nextval);
  4  end loop;
  5  commit;
  6  end;
  7  /

PL/SQL procedure successfully completed.

scott@9i > create sequence mysequence2 start with 1 increment by 1 cache 10;

Sequence created.

scott@9i > begin
  2  for mag in 1..12 loop
  3  insert into t2 values (mysequence2.nextval);
  4  end loop;
  5  commit;
  6  end;
  7  .
scott@9i > /

PL/SQL procedure successfully completed.
 

scott@9i > select mysequence1.currval from dual;

   CURRVAL
----------
        12

scott@9i > select mysequence2.currval from dual;

   CURRVAL
----------
        12


scott@9i > !exp scott/tiger owner=scott file=scott.dmp

Export: Release 9.2.0.4.0 - Production on Thu Jun 9 08:46:58 2005

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to: Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses WE8ISO8859P1 character set (possible charset conversion)

About to export specified users ...
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user SCOTT
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user SCOTT
About to export SCOTT's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export SCOTT's tables via Conventional Path ...
. . exporting table                             T1         12 rows exported
. . exporting table                             T2         12 rows exported
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.

scott@9i >  select 'drop '||table_type ||' '||table_name||';' from cat;

'DROP'||TABLE_TYPE||''||TABLE_NAME||';'
------------------------------------------------
drop SEQUENCE MYSEQUENCE1;
drop SEQUENCE MYSEQUENCE2;
drop TABLE T1;
drop TABLE T2;

scott@9i > drop SEQUENCE MYSEQUENCE1;
drop SEQUENCE MYSEQUENCE2;
drop TABLE T1;
drop TABLE T2;

Sequence dropped.

scott@9i >
Sequence dropped.

scott@9i >
Table dropped.

scott@9i >
Table dropped.

scott@9i > !imp scott/tiger fromuser=scott touser=scott file=scott.dmp ignore=y

Import: Release 9.2.0.4.0 - Production on Thu Jun 9 08:50:54 2005

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to: Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production

Export file created by EXPORT:V09.02.00 via conventional path
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses WE8ISO8859P1 character set (possible charset conversion)
. . importing table                           "T1"         12 rows imported
. . importing table                           "T2"         12 rows imported
Import terminated successfully without warnings.


scott@9i > select mysequence1.nextval from dual;

   NEXTVAL
----------
        13

scott@9i > select mysequence2.nextval from dual;

   NEXTVAL
----------
        21

Re: State of sequence in full db exp/imp [message #122998 is a reply to message #122967] Thu, 09 June 2005 09:28 Go to previous messageGo to next message
smartin
Messages: 1803
Registered: March 2005
Location: Jacksonville, Florida
Senior Member
Mahesh, that is a good and useful demo.

OP, the important thing is that Oracle maintains the sequence so that when you start getting values from it again you will not get any duplicate values. That is all a sequence is for: to provide a fast way to get unique values. There is no guarantee that they will always be sequential or won't have gaps. But there is a guarantee that they will be unique, so even when you export and import, as demo'd, you don't have to manually reset each sequence to prevent duplicates.
Re: State of sequence in full db exp/imp [message #123000 is a reply to message #122998] Thu, 09 June 2005 09:35 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
smartin wrote:
>>There is no guarantee that they will always be sequential or won't have gaps.
True. I forgot to mention that.
Re: State of sequence in full db exp/imp [message #123022 is a reply to message #123000] Thu, 09 June 2005 10:32 Go to previous messageGo to next message
smartin
Messages: 1803
Registered: March 2005
Location: Jacksonville, Florida
Senior Member
Mahesh Rajendran wrote on Thu, 09 June 2005 10:35

smartin wrote:
>>There is no guarantee that they will always be sequential or won't have gaps.
True. I forgot to mention that.



Maybe or maybe not, but your demo implied it pretty strongly Cool
Re: State of sequence in full db exp/imp [message #123111 is a reply to message #123022] Thu, 09 June 2005 19:46 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
Well they'll be unique unless they cycle...

create sequence seq1 maxvalue 5 cache 4 cycle;
select seq1.nextval from user_objects where rownum < 9;

1
2
3
4
5
1
2
3
Re: State of sequence in full db exp/imp [message #123216 is a reply to message #123111] Fri, 10 June 2005 10:06 Go to previous message
smartin
Messages: 1803
Registered: March 2005
Location: Jacksonville, Florida
Senior Member
andrew again wrote on Thu, 09 June 2005 20:46

Well they'll be unique unless they cycle...



Good point Cool
Previous Topic: unable to extend TEMP -- Did I do all that needs to be done?
Next Topic: where is my DDL by which i created table?
Goto Forum:
  


Current Time: Fri Jan 10 07:17:52 CST 2025