Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Oracle dbms_random

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Oracle dbms_random

Introduce several commonly used functions to generate 0-1 decimals (default)

SQL > select dbms_random.valuefrom dual

VALUE

-

. 932351752

Note: the result can be processed by trunc and round functions

Generate a number within the specified range

FUNCTION VALUE RETURNS NUMBER

Argument Name Type In/Out Default?

-

LOW NUMBER IN

HIGH NUMBER IN

SQL > select dbms_random.value (235.48) from dual

DBMS_RANDOM.VALUE (23,048)

-

23.1991482

Note: the result can be processed by trunc and round functions

A random number string of length 20

SQL > select length (cast (dbms_random.valueas varchar2 (1024) from dual

LENGTH (CAST (DBMS_RANDOM.VALUEASVARCHAR2 (1024)

thirty-nine

It means that only 38 placeholders have numbers after the decimal point.

SQL > select substr (cast (dbms_random.valueas varchar2 (38)), 3Jing 20) from dual

SUBSTR (CAST (DBMS_RANDOM.VALUEASVARCHAR2)

-

52633757378080443317

Random number of normal distribution

Select dbms_random.normal from dual

Random string

Select dbms_random.string (opt, length) fromdual

Available values for opt are as follows:

'upright grammar': uppercase letters

'l 'er': lowercase letters.

'a small letter': upper and lowercase letters

'x numbers, uppercase letters

'pendant dint': printable characters

SQL > select dbms_random.string ('Utopia 10) from dual

DBMS_RANDOM.STRING ('Utopia 10)

- -

DTKOJUGGHI

Summary: random dates and random strings can be realized through dbms_random, and those with random changes can be converted using this function.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report