ORACLE ÈçºÎ²úÉúÒ»¸öËæ»úÊý
ORACLE ÈçºÎ²úÉúÒ»¸öËæ»úÊý:DBMS_RANDOM
--1¡¢Ð¡Êý( 0 ~ 1)
select dbms_random.value from dual ;
--2¡¢Ö¸¶¨·¶Î§ÄÚµÄСÊý ( 0 ~ 100 )
select dbms_random.value(0,100) from dual ;
--3¡¢Ö¸¶¨·¶Î§ÄÚµÄÕûÊý ( 0 ~ 100 )
select trunc(dbms_random.value(0,100)) from dual ;
--4¡¢³¤¶ÈΪ20µÄËæ»úÊý×Ö´®
select substr(cast(dbms_random.value as varchar2(38)),0,10) from dual ;
--5¡¢Õý̬·Ö²¼µÄËæ»úÊý
select dbms_random.normal from dual ;
--6¡¢Ëæ»ú×Ö·û´®
select dbms_random.string('x', 3) from dual ;
/* opt¿ÉȡֵÈçÏ£º
'u','U' : ´óд×Öĸ
'l','L' : Сд×Öĸ
'a','A' : ´ó¡¢Ð¡Ð´×Öĸ
'x','X' : Êý×Ö¡¢´óд×Öĸ
'p','P' : ¿É´òÓ¡×Ö·û*/
--7¡¢Ëæ»úÈÕÆÚ
select to_date(2454084+TRUNC(DBMS_RANDOM.VALUE(0,365)),'J') from dual ;
/* ͨ¹ýÏÂÃæµÄÓï¾ä»ñµÃÖ¸¶¨ÈÕÆÚµÄ»ùÊý*/
select to_char(sysdate,'J') from dual ;
--8¡¢Éú³ÉGUID
select sys_guid() from dual ;
--Éú³É´ø·Ö¸ô·û(-)µÄGUIDµÄ×Ô¶¨Ò庯Êý
--create or replace function my_guid
return varchar2
is
guid varchar(36);
temp varchar(32);
begin
temp:=sys_guid();
guid:= substr(temp,1,8) || '-'
||substr(temp,9,4) || '-'
||substr(temp,13,4)|| '-'
||substr(temp,17,4)|| '-'
||substr(temp,21,12)
Ïà¹ØÎĵµ£º
BLOBµÄº¬Òå¡¡¡¡
BLOB (binary large object)£¬¶þ½øÖÆ´ó¶ÔÏó£¬ÊÇÒ»¸ö¿ÉÒÔ´æ´¢¶þ½øÖÆÎļþµÄÈÝÆ÷¡£
¡¡¡¡ÔÚ¼ÆËã»úÖУ¬BLOB³£³£ÊÇÊý¾Ý¿âÖÐÓÃÀ´´æ´¢¶þ½øÖÆÎļþµÄ×Ö¶ÎÀàÐÍ¡£
¡¡¡¡BLOBÊÇÒ»¸ö´óÎļþ£¬µäÐ͵ÄBLOBÊÇÒ»ÕÅͼƬ»òÒ»¸öÉùÒôÎļþ£¬ÓÉÓÚËüÃǵijߴ磬±ØÐëʹÓÃÌØÊâµÄ·½Ê½À´´¦Àí£¨ÀýÈ磺ÉÏ´«¡ ......
֮ǰ¿ª·¢OracleÒ»°ãÊÇʹÓÃPL/SQL Developer»òÕßÊÇTOAD£¬ÓÉÓÚÏÖÔÚ¹«Ë¾¶Ô°æÈ¨ÎÊÌâ¿´µÃ±È½ÏÖØ£¬ËùÒÔÎÒÒ²Ö»ÄܶÔÕâЩÊìϤµÄ¿ª·¢¹¤¾ß˵Éù°Ý°ÝÁË£¡ÔÚOracle¹Ù·½ÍøÕ¾Õ¾¿´µ½ÁËOracleÒѾÓÐÁËÒ»¸öOracle SQL Developer£¬²¢ÇÒÊÇÃâ·ÑµÄ£¡
ÒÔÏÂÊÇOracle¹Ù·½¶ÔOracle SQL DeveloperµÄ½éÉÜ
³ÌÐò´úÂë
orac ......
ÔÚ×öÓ¦ÓÃϵͳ¿ª·¢Ê±£¬ÎÒÃÇ»áÓöµ½Ò»¸öÎÊÌ⣬¾ÍÊÇÎÒÃÇÓ¦ÓÃϵͳÓÐЩÊý¾ÝÐèÒª´ÓÆäËûÊý¾Ý¿âµÄijһÕűíÄõ½Êý¾Ý£¬ÄÇÎÒÃÇÓ¦¸ÃÔõô°ì£¿±ÈÈ磺×Ó¹«Ë¾µÄÏúÊÛϵͳÐèÒª´Ó¹ãÖÝ×ܲ¿ÈËÁ¦×ÊÔ´¹ÜÀíϵͳµÄÊý¾Ý¿âµ±ÖлñÈ¡×îеÄÓû§ÐÅÏ¢£¬ÄÇÎÒÃÇÓ¦¸ÃÔõôʵÏÖ£¿ÊµÏÖÏÖÔÚµÄ×ö·¨Óкܶ࣬¿ÉÒÔͨ¹ýWebService·½Ê½»ñÈ¡£¬µ«¿ª·¢³É±¾»¹ÊDZȽϸߣ¬¼ÙÉè ......
PL/SQLÊǶÔOracleÊý¾Ý¿â½øÐвÙ×÷µÄÒ»ÖÖ¹ý³ÌÐÔ±à³ÌÓïÑÔ£¬Ëü¿ÉÒÔÔÚSQL * plusÖÐÖ´ÐУ¬Ò²¿ÉÒÔǶÈëµ½JAVA»òÕßC++ÖС£Æä»ù±¾×é³ÉΪ£º
DECLARE
...
BEGIN
...
EXCEPTION
...
END
¿ÉÓÃÀ´½«¶ÔÊý¾Ý¿âµÄ¸÷ÖÖ²Ù×÷·âװΪһ¸ö´úÂë¿é£¬ÎªÁ˼ÓÇ¿¿ÉÖØÓÃÐÔ£¬»¹¿É½«Öظ´ÐÔ´úÂëд³Éº¯ÊýÓë´æ´¢¹ý³Ì£¬Ó ......
OracleÈÕÆÚº¯Êý¼¯½õ(Ò»)
Ò»¡¢ ³£ÓÃÈÕÆÚÊý¾Ý¸ñʽ
1.Y»òYY»òYYY ÄêµÄ×îºóһ룬Á½Î»»òÈýλ
SQL> Select to_char(sysdate,'Y') from dual;
TO_CHAR(SYSDATE,'Y')
--------------------
7
SQL> Select to_char(sysdate,'YY') from dual;
TO_CHAR(SYSDATE,'YY')
---------------------
07
SQL> Select to_ch ......