Oracle中批量导出Sequence

 
Java代码
  1. select 'create sequence '||sequence_name||   
  2.        ' minvalue '||min_value||   
  3.        ' maxvalue '||max_value||   
  4.        ' start with '||last_number||   
  5.        ' increment by '||increment_by||   
  6.         (case when cache_size=0 then ' nocache' else ' cache '||cache_size end) ||';'  
  7. from dba_sequences where sequence_owner='HR'  


注意:其中的HR,是需要导出sequence的用户,貌似必须大写的说!并且使用该脚本的用户需要有访问dba_sequences的权限。

导出结果如下:

Java代码
  1. create sequence HIBERNATE_SEQUENCE minvalue 1 maxvalue 999999999999999999999999999 start with 1 increment by 1 cache 20;   
  2. create sequence MIAGENTVERSION_VERSION_SEQ minvalue 1 maxvalue 999999999999999999999999 start with 121 increment by 1 cache 20;  

  方法二:

  select dbms_metadata.get_ddl('SEQUENCE',u.object_name) from user_objects u where object_type='SEQUENCE'

  结果类似:

  CREATE SEQUENCE "MO_VO"."ARTCOMMENT_SEQ" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 341 CACHE 20 ORDER NOCYCLE ;

  CREATE SEQUENCE "MO_VO"."ARTICLEVISTCECOLLECT_SEQ" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 ORDER NOCYCLE ;

  CREATE SEQUENCE "MO_VO"."ARTICLEVISTTEMP_SEQ" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 82989 CACHE 20 ORDER NOCYCLE ;

  CREATE SEQUENCE "MO_VO"."ARTICLEVIST_SEQ" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1675 CACHE 20 ORDER NOCYCLE ;

你可能感兴趣的:(java,oracle,Hibernate,cache,object,脚本)