当前位置:网站首页>Kingbasees plug-in DBMS of Jincang database_ RANDOM

Kingbasees plug-in DBMS of Jincang database_ RANDOM

2022-06-25 11:07:00 Thousands of sails pass by the side of the sunken boat_



1. DBMS_RANDOM


1.1. DBMS_RANDOM Introduce
KingbaseES Provides DBMS_RANDOM Random data generation function defined under the system package .DBMS_RANDOM The system package provides a random number or character generator .
You need to create extension dbms_random, When you don't need to drop extension dbms_random that will do .
The following table lists them DBMS_RANDOM System packages and a brief description of them .
surface 1 DBMS_RANDOM Package subroutines and functions

Subroutines / function
describe
INITIALIZE
Use a seed value to initialize the package
NORMAL Function
Produce a standard normal distribution function
RANDOM Function
Generate a random integer
SEED Procedure
Reset random number seed
STRING Function
Generate a random string
TERMINATE Procedure
Provides syntactic compatibility without performing any operations
VALUE Function
Generates a random number in a specified range

2. INITIALIZE Procedure


Use a seed value to initialize DBMS_RANDOM package , By default ,DBMS_RANDOM The package is based on the user 、 Time 、 Session to initialize .Initialize This function is obsolete , Although currently supported , However, this initialization method is reserved for historical reasons and compatibility .
Grammar format :

DBMS_RANDOM.INITIALIZE(init INTEGER);

Parameter description :

surface 2 initialize Parameters
Parameters
describe
init
Random number seed value

Return value description :
VOID
Example :

CALL dbms_random.initialize(8);


3. NORMAL Function


Produce a standard normal distribution function , The standard deviation of this normal distribution is 1, The expected value is 0.
Grammar format :

DBMS_RANDOM.NORMAL();

Parameter description :
No arguments
Return value description :DOUBLE
Example :

SELECT dbms_random.normal();


4. RANDOM Function


Generate a random integer , This function is out of date , Although it still supports , But it should not be used , Keep this function for compatibility .
Grammar format :

DBMS_RANDOM.RANDOM();

Parameter description :
No arguments
Return value description :
NTEGER
Example :

CALL dbms_random.random();


5. SEED Procedure


Reset seed , Be similar to initialize function ,initialize Functions have been eliminated . seed Function supports both numeric and character values as seed values , and initialize Only numerical values are supported .
Grammar format :

DBMS_RANDOM.SEED(i INTEGER);
DBMS_RANDOM.SEED(t TEXT);

Parameter description :

surface 3 seed Parameters
Parameters
describe
i
Random number seed value
t
Random number symbol seed value

Return value description :

surface 4 seed Return value
function
type
SEED(i INTEGER)
VOID
SEED(t TEXT)
VOID

Example :

CALL dbms_random.seed(8);
CALL dbms_random.seed('test');



6. STRING Function


Get a random string , The first parameter is the format of the string , The second parameter is the length of the string . Maximum length 5000, If the parameter exceeds 5000 Will automatically use 5000 Handle .
Grammar format :

DBMS_RANDOM.STRING(type TEXT,len INTEGER);

Parameter description :

surface 5  string Parameters
 
Parameters
describe
type
The type of string generated
len
The length of the resulting string
surface 6  type The corresponding meaning of the parameter
'x','X'
Returns a string of uppercase letters and numbers
'p','P'
Returns a string of any printable character

Return value description :
TEXT
Example :

SELECT dbms_random.string('U',5);
SELECT dbms_random.string('P',2);
SELECT dbms_random.string('x',4);
SELECT dbms_random.string('a',2);
SELECT dbms_random.string('l',3);


7. TERMINATE Procedure


The original function is to finish using dbms_random Execute this function when package , But now this function does nothing , Reserved for syntax compatibility .
Grammar format :

DBMS_RANDOM.TERMINATE();

Parameter description :
No arguments
Return value description :
VOID
Example :

CALL dbms_random.terminate();


8. VALUE Function


The first way to use no parameters is to get a value greater than or equal to 0 And less than 1 The random number , Accuracy of 16 Decimal place .
In the second way, you can specify the minimum and maximum values , The range of the return value is greater than or equal to low, Less than high, The accuracy is the same as 16 Decimal place .
Grammar format :

DBMS_RANDOM.VALUE();
DBMS_RANDOM.VALUE(low INTEGER,high INTEGER);

Parameter description :

surface 7 value Parameters
Parameters
describe
low
The minimum value of the generated random number
high
The maximum value of the generated random number

 

Return value description :

surface 8 value Return value
function
type
VALUE()
VOID
VALUE(low INTEGER,high INTEGER)
VOID

Example :

SELECT dbms_random.value();
SELECT dbms_random.value(10,15);

原网站

版权声明
本文为[Thousands of sails pass by the side of the sunken boat_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206251044550089.html