|
IOTN :: Field Book :: ORACLE
dbms_random »ç¿ë¿¹
|
ÃÖ±æÈ£
[LIST]
|
2010-04-12 15:09:44, Á¶È¸ : 81,336 |
select * from tab order by dbms_random.value
-- EXEC DBMS_RANDOM.INITIALIZE (12345);
drop table info purge ;
create table info (user_cd int, id varchar2(15));
insert into info value
select rownum, round(dbms_random.value(60,90))
||trim(to_char(dbms_random.value(1,12),'09'))
||trim(to_char(dbms_random.value(1,31),'09'))
||'-'
||round(dbms_random.value(1,2))
||round(dbms_random.value(100001,999999)) id
from dual
connect by level < 200001;
commit;
-- sample
ROWNUM ID
---------- ---------------
1 830404-1136385
2 790411-2591577
3 780428-1110061
4 811205-1954727
5 721016-2808174
6 851005-2557025
7 740610-2416417
8 730213-2778423
9 810502-1141398
10 820712-2589165
11 761231-1393948
-- ±âŸ
select rownum, dbms_random.value(1,2), RPAD('x',(rownum/10),'x')
from dual
connect by level < 100000
| 18.97.9.172
|
|
|
|
|
ÆÐÅ°Áö : DBMS_RANDOM
ÆÐÅ°Áö»ý¼º: /rdbms/admin/dbmsrand.sql
DBMS_RANDOM ÆÐÅ°Áö³» ÇÔ¼ö
RANDOM : ·£´ýÇÑ ¼ýÀÚ »ý¼º
VALUE : ·£´ýÇÑ ¼ýÀÚ »ý¼º(ÁöÁ¤ÇÑ ¹üÀ§¿¡¼, µðÆúÆ®: 0-1)
STRING : ·£´ýÇÑ ¹®ÀÚ¿ »ý¼º(¹®ÀÚ¿ÀÇ ±¸¼ºÀº ù¹ø° Àμö°ªÀ¸·Î ÁöÁ¤.)
ù¹ø° Àμö°ª
U - ´ë¹®ÀÚ
L - ¼Ò¹®ÀÚ
A - Alphanumeric
X - Alphanumeric (´ë¹®ÀÚ·Î µÈ)
P - Ãâ·Â°¡´ÉÇÑ ¹®Àڷθ¸
µÎ¹ø° Àμö°ª - ¹®ÀÚ¿±æÀÌ ÁöÁ¤
INITIALIZE : seed¼ýÀÚ¸¦ ÅëÇÑ ÆÐÅ°ÁöÀÇ ÃʱâÈ
SEED : seed¼ýÀÚ¸¦ º¯°æ
TERMINATE : Á¾·á
STRING ÇÔ¼ö¿¡¼ A, XÀÇ °æ¿ì ¾ËÆÄ´º¸Þ¸¯À¸·Î »ý¼ºµÈ´Ù°í ÇßÁö¸¸,
¿©·¯¹ø Å×½ºÆ®ÇØ º¸¾ÒÁö¸¸ ¼ýÀÚ°¡ Æ÷ÇÔµÇ¾î »ý¼ºµÇ´Â °æ¿ì´Â ¾ø¾ú´Ù.
½Å·ÚÇÏÁö ¾Ê´Â °ÍÀÌ ÁÁ°Ú´Ù.
¿¹
SQL> col random format 999999999999999999999
SQL> select dbms_random.random from dual; ·£´ýÇÑ ¼ýÀÚ Ãâ·Â(¾ç¼ö/À½¼ö)
RANDOM
----------------------
712490986
SQL> /
RANDOM
----------------------
-265131627
SQL> select dbms_random.value from dual; ·£´ýÇÑ ¼ýÀÚ Ãâ·Â(0~1»çÀÌ)
VALUE
----------
.479131147
SQL> select dbms_random.value(1,1000) random from dual; 1~1000»çÀÌÀÇ ¼ýÀÚ
RANDOM
----------------------
727
SQL> select dbms_random.value(100000000000, 999999999999) random from dual; À§¿Í ¸¶Âù°¡Áö
RANDOM
----------------------
314598161006
SQL> set linesize 50
SQL> select dbms_random.string('U', 20) str from dual; ´ë¹®ÀÚ·Î µÈ ·£´ýÇÑ ¹®ÀÚ¿
STR
--------------------------------------------------
MAFMGVJVTUTCYJMCVJOP
SQL> select dbms_random.string('L', 20) str from dual; ¼Ò¹®ÀÚ·Î µÈ ·£´ýÇÑ ¹®ÀÚ¿
STR
--------------------------------------------------
ntpmvektqqgytitlmabi
SQL> select dbms_random.string('A', 20) str from dual; ´ë/¼Ò¹®ÀÚ·Î µÈ ·£´ýÇÑ ¾ËÆÄ´º¸Þ¸¯(¹®ÀÚ/¼ýÀÚ)
STR
--------------------------------------------------
jhsVWesqaKAJbKuPJeLu
SQL> select dbms_random.string('X', 20) str from dual; ´ë¹®ÀÚ·Î µÈ ·£´ýÇÑ ¾ËÆÄ´º¸Þ¸¯(¹®ÀÚ/¼ýÀÚ)
STR
--------------------------------------------------
GMRG5IJFEIEI0E0YCG9C
SQL> select dbms_random.string('P', 20) str from dual;
STR
--------------------------------------------------
}t.OY)Sh6AiEq4L>=-K+
SQL>
http://duraboys.tistory.com/entry/·£´ýRandomÇÑ-¼ýÀÚ¹®ÀÚ-»ý¼ºÇϱâ-1 |
2010-09-12 06:04:26
|
|
Copyright 1999-2024 Zeroboard / skin by ÃÖ±æÈ£(gilho.kr@gmail.com)
|
|
|