ORCALE SYNONYM && SEQUENCE

一、SYNONYM

1.CREATE

   CREATE SYNONYM dept FOR SCOTT.dept;

2.DROP

   DROP SYNONYM dept;

3.CREATE PUBLIC SYNONYM

   CREATE PUBLIC SYNONYM dept FOR SCOTT.dept

4.DISPLAY SYNONYM

  DESC DBA_SYNONYMS;

  DESC USER_SYNONYMS;

 

二、SEQUENCE

1.CREATE

  CREATE SEQUENCE myseq
  START WITH 1  --start from the value
  INCREMENT BY 1 --increace 1 one time
  ORDER             
  NOCYCLE            
  /

2.DISPLAY

  SELECT  myseq.NEXTVAL FROM dual;

  SELECT myseq.CURRVAL FROM dual;

3.DISPLAY SEQUENCES

   DESC DBA_SEQUENCES;

   DESC USER_SEQUENCES;

 NOTE:First, should use NEXTVAL, and then the CURRVAL has value.

          When the DB Server stopped, though the myseq has value, but you should first use NEXTVAL too, and then you could select the CURRVAL.

 

 

你可能感兴趣的:(sequence)