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)
相关文档:
1、备份指定的表空间
首先,你要确认自己电脑上有exp.exe这个东东,才能进行备份工作。
我想要备份的是用户名为cyy的表空间,备份文件打算放在D盘,并以backup_oracle.dmp命名,顺便把日志文件也备份一下好了。
在命令行敲入:
C:\Documents and Settings\Administrator>exp cyy/cyy@bsrs file=D:\backup_oracle.dmp ......
An introduction to Mutexes in 10gR2
By Connie Green, Kumar Rajamani
from meetings with: Kumar Rajamani, Russell Green, Saureen Shah, Cecilia Gervasio and Connie Green
Introduction
This paper is intended as an introduction to mutexes. It describes new concepts associated with mutexes, when ......
备份的方法
ORACLE数据库有三种标准的备份。导出/导入(EXPORT/IMPORT) 、冷备份、热备份。
导出备份是一种逻辑备份,这种方法包括读取一系列的数据库日志,并写入文件中,这些日志的读取与其所处位置无关。
冷备份和热备份是物理备份(也称低级备份),它涉及到 ......
一:无返回值的存储过程
存储过程为:
create or replace procedure adddept(deptno number,dname varchar2,loc varchar2)
as
begin
insert into dept values(deptno,dname,loc);
end;
然后呢,在java里调用时就用下面的代码:
public class TestProcedure {
Connectio ......
在做应用系统开发时,我们会遇到一个问题,就是我们应用系统有些数据需要从其他数据库的某一张表拿到数据,那我们应该怎么办?比如:子公司的销售系统需要从广州总部人力资源管理系统的数据库当中获取最新的用户信息,那我们应该怎么实现?实现现在的做法有很多,可以通过WebService方式获取,但开发成本还是比较高,假设 ......