Oracle×ÔÔöIDʵÏÖ
Ê×ÏÈ£¬ÄãÒªÓÐÒ»ÕÅ±í£¡
CREATE TABLE example(
ID Number(4) NOT NULL PRIMARY KEY,
NAME VARCHAR(25),
PHONE VARCHAR(10),
ADDRESS VARCHAR(50) );
È»ºó£¬ÄãÐèÒªÒ»¸ö×Ô¶¨ÒåµÄ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»Á¬¹á.(Èç¹ûÁ¬²»Á¬¹áÎÞËùν½¨ÒéÓÃcache,ÒòΪʱ¼ä¾ÍÊǽðǮѽ!ÅÜÌâÁË£¡)
Êé½ÓÉÏÎÄ£¬ÄãÖ»ÓÐÁ˱íºÍÐòÁл¹²»¹»£¬»¹ÐèÒªÒ»¸ö´¥·¢Æ÷À´Ö´ÐÐËü£¡´úÂëÈçÏ£º
CREATE TRIGGER "´¥·¢Æ÷Ãû³Æ" BEFORE
INSERT ON example FOR EACH ROW WHEN (new.id is null)
begin
select emp_sequence.nextval into: new.id from dual;
end;
´òÍêÊÕ¹¤£¡ÏÂÃæÄã¾ÍÊÔÊÔ²åÈëÊý¾Ý°É£¡
INSERT INTO example
Ïà¹ØÎĵµ£º
ËäȻѧϰJavaºÜ¾ÃÁË£¬×Ô¼ºÒ²Á¬½Ó¹ýһЩÊý¾Ý¿â£¬±ÈÈçmysqlÖ®ÀàµÄ£¬Èç½ñÄØ£¬Ò²Ñ§Ï°ÁËÒ»¶Îʱ¼äµÄOracle£¬È»¶øÄØ£¬½ñÌìÊÇÎÒµÚÒ»´ÎÁ¬½ÓOracle£¬ºÙºÙ£¬Ó¦¸Ã»¹²»ËãÌ«³Ù°É¡£
½ñÌìÄØ£¬Óе㱿׾£¬´ó¼ÒĪЦ£¡
ÎÒÕâÊÇÒ»¸ö²éѯÀý×Ó
Ê×ÏÈ£¬Ô ......
´´½¨ÁÙʱ±í¿Õ¼ä
´´½¨ÁÙʱ±í¿Õ¼ä
CREATE TEMPORARY TABLESPACE test_temp
TEMPFILE 'C:\oracle\product\10.1.0\oradata\orcl\test_temp01.dbf'
SIZE 32M
AUTOEXTEND ON
NEXT 32M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL;
´´½¨Óû§±í¿Õ¼ä
´´½¨Óû§±í¿Õ¼ä
C ......
oracleµÄ·ÖÎöº¯Êýover ¼°¿ª´°º¯Êý
Ò»£º·ÖÎöº¯Êýover
Oracle´Ó8.1.6¿ªÊ¼Ìṩ·ÖÎöº¯Êý£¬·ÖÎöº¯ÊýÓÃÓÚ¼ÆËã»ùÓÚ×éµÄijÖÖ¾ÛºÏÖµ£¬ËüºÍ¾ÛºÏº¯ÊýµÄ²»Í¬Ö®´¦ÊÇ
¶ÔÓÚÿ¸ö×é·µ»Ø¶àÐУ¬¶ø¾ÛºÏº¯Êý¶ÔÓÚÿ¸ö×éÖ»·µ»ØÒ»ÐС£
ÏÂÃæÍ¨¹ý¼¸¸öÀý×ÓÀ´ËµÃ÷ÆäÓ¦Óᣠ&nb ......
ÔÚÃüÁî¸ñʽÏ£¬½øÈësqlplusµÄ±à¼×´Ì¬ÖÐ
£¨1£©²é¿´¿ØÖÆÎļþµÄÄÚÈÝ£º
SQL> DESC v$controlfile
Ãû³Æ &n ......