Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

OracleÖÐ×ÔÔö×ֶεĴ´½¨

²½Ö裺
1.Ê×ÏÈ£¬ÄãÒªÓÐÒ»ÕÅ±í£¡
       CREATE TABLE example(
             ID Number(4) NOT NULL PRIMARY KEY,
             NAME VARCHAR(25),
             PHONE VARCHAR(10),
             ADDRESS VARCHAR(50)
          );
2.È»ºó£¬ÄãÐèÒªÒ»¸ö×Ô¶¨ÒåµÄsequence
     CREATE SEQUENCE emp_sequence
          INCREMENT BY 1 -- ÿ´Î¼Ó¼¸¸ö
          START WITH 1 -- ´Ó1¿ªÊ¼¼ÆÊý
          NOMAXVALUE -- ²»ÉèÖÃ×î´óÖµ
          NOCYCLE -- Ò»Ö±ÀÛ¼Ó£¬²»Ñ­»·
          NOCACHE -- ²»½¨»º³åÇø
         ÒÔÉÏ´úÂëÍê³ÉÁËÒ»¸öÐòÁÐ(sequence)µÄ½¨Á¢¹ý³Ì,Ãû³ÆΪemp_sequence,·¶Î§ÊÇ´Ó1¿ªÊ¼µ½ÎÞÏÞ´ó(ÎÞÏÞ´óµÄ³Ì¶ÈÊÇÓÉÄã»úÆ÷¾ö¶¨µÄ),nocycle ÊǾö¶¨²»Ñ­»·,Èç¹ûÄãÉèÖÃÁË×î´óÖµÄÇôÄã¿ÉÒÔÓÃcycle »áʹseqµ½×î´óÖ®ºóÑ­»·.¶ÔÓÚnocache˳±ã˵һÏÂÈç¹ûÄã¸ø³öÁËcacheÖµÄÇôϵͳ½«×Ô¶¯¶ÁÈ¡ÄãµÄcacheÖµ´óС¸öseq
,ÕâÑùÔÚ·´¸´²Ù×÷ʱ»á¼Ó¿ìÔËÐÐËÙ¶È,µ«Èç¹ûÔâÓöÒâÍâÇé¿öÈçµ±»úÁË»òoracleËÀÁË,ÔòÏ´ÎÈ¡³öµÄseqÖµ½«ºÍÉϴεIJ»Á¬¹á
3.»¹ÐèÒªÒ»¸ö´¥·¢Æ÷À´Ö´ÐÐËü£¡´úÂëÈçÏ£º
     CREATE TRIGGER autoIncre BEFORE
          INSERT ON example FOR EACH ROW WHEN (new.id is null)
      begin
          select emp_sequence.nextval into :new.id from dual;
       end;
       ÒÔÉϲ


Ïà¹ØÎĵµ£º

oracle ±í¿Õ¼ä²Ù×÷

oracle±í¿Õ¼ä²Ù×÷Ïê½â
  1
  2
  3×÷Õߣº   À´Ô´£º    ¸üÐÂÈÕÆÚ£º2006-01-04 
  5
  6 
  7½¨Á¢±í¿Õ¼ä
  8
  9CREATE TABLESPACE data01
 10DATAFILE '/ora ......

oracle¸´Ï°£¨Ò»£© Ö®OracleÌåϵ½á¹¹

      ѧϰOracle DBAÒ²°ë¸ö¶àѧÆÚÁË£¬½ñÌìÃÍÈ»²Å·¢ÏÖ£¬Ô­À´ÎÒµÄÊ黹ÊǺÜеģ¬ÉϿβÙ×÷ʱºòÒ²Ö»ÊÇÖªµÀ´ó¸ÅÔõô×ö£¬µ«ÊÇÒªÕæµÄÈ«²¿×Ô¼º×ö£¬¶ø²»È¥·­Ê黹ÊÇÓÐÒ»¶¨µÄÄѶȵģ¬ËùÒÔÄØ£¬½ñÌ쿪ʼ½«DBA´ÓÍ·¸´Ï°Ò»±é£¬Í¬Ê±ÔÙ²Ù×÷Ò»±é¡£
      µÚÒ»Õ£¬Ñ§µÄÊÇOracleµÄÌåϵ½á¹¹£ ......

OracleÖÐÀûÓÃÒ»ÌõSQLÉú³É10ÍòÌõ¼Ç¼

  ×öÊý¾Ý¿â¿ª·¢»ò¹ÜÀíµÄÈ˾­³£Òª´´½¨´óÁ¿µÄ²âÊÔÊý¾Ý£¬¶¯²»¶¯¾ÍÐèÒªÉÏÍòÌõ£¬Èç¹ûÒ»ÌõÒ»ÌõµÄ¼È룬ÄÇ»áÀË·Ñ´óÁ¿µÄʱ¼ä£¬±¾ÎĽéÉÜÁËOracleÖÐÈçºÎͨ¹ýÒ»ÌõSQL¿ìËÙÉú³É´óÁ¿µÄ²âÊÔÊý¾ÝµÄ·½·¨¡£
²úÉú²âÊÔÊý¾ÝµÄSQLÈçÏ£º
SQL> select rownum as id,
  2         &nb ......

oracleÈÕÆÚº¯Êý¼¯ ÉîδÀ´

OracleÔÚÈÕÆÚʹÓÃÉÏÔÊÐí¼«´óµÄÁé»îÐÔ¡£ÓÉÓÚ¿ÉÒÔÔÚÈÕÆÚ×ֶδ洢ʱ¼äºÍÈÕÆÚ£¬´Ó¶øÓк¯Êý¿ÉÒÔ¼ÈÒýÓÃÈÕÆÚÓÖÒýÓÃʱ¼ä¡£
Oracle ËùÌṩµÄһЩÈÕÆÚº¯ÊýÈçÏÂËùʾ¡£
1. SYSDATE
·µ»Øµ±Ç°µÄÈÕÆÚºÍʱ¼ä¡£
ʾÀý
SELECT sysdate from dual;
SYSDATE
----------
05-3ÔÂ -03
2. ADD_MONTHS(d, no_of_month)
µ±Ç°ÈÕÆÚ"m"ºóÍÆ"no_o ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ