oracle增加md5函数

2015-09-22

oracle增加md5函数,md5作为密码实例。

1、oracle增加md5函数
CREATE OR REPLACE FUNCTION MD5(passwd IN VARCHAR2) RETURN VARCHAR2 IS
retval varchar2(32);
BEGIN
retval := Lower(utl_raw.cast_to_raw(
DBMS_OBFUSCATION_TOOLKIT.MD5(INPUT_STRING => passwd))
);
RETURN retval;
END;

或者
CREATE OR REPLACE FUNCTION MD5 (input_string VARCHAR2) return varchar2
IS raw_input RAW(128) := UTL_RAW.CAST_TO_RAW(input_string);
decrypted_raw RAW(2048);
error_in_input_buffer_length EXCEPTION;
BEGIN
sys.dbms_obfuscation_toolkit.MD5(input => raw_input, checksum => decrypted_raw);
return lower(rawtohex(decrypted_raw));
END;

2、实例
select USER_NAME,password from FT_USER where password=md5('$oldpw') order by USER_NAME;
update FT_AGENT_USER set password=md5('$newpw') where password=md5('$oldpw');
select USER_NAME,password from FT_USER where password=md5('$newpw') order by USER_NAME;
commit;

3、dbms_metadata.get_ddl()用于获取对象的DDL,检查md5源码

set line 200
set pagesize 0
set long 99999
set feedback off
set echo off

select dbms_metadata.get_ddl('TABLE','TABLE_NAME','TABLE_OWNER') from dual;
select dbms_metadata.get_ddl('TABLE','TABLE_NAME','TABLE_OWNER') from dual;
select dbms_metadata.get_ddl('INDEX','INDEX_NAME','INDEX_OWNER') from dual;
select dbms_metadata.get_ddl('VIEW','VIEW_NAME','VIEW_OWNER') from dual;
select dbms_metadata.get_ddl('PROCEDURE','PROCEDURE_NAME','PROCEDURE_OWNER') from dual;
select dbms_metadata.get_ddl('FUNCTION','FUNCTION_NAME','FUNCTION_OWNER') from dual;

set pagesize 0
set long 90000
set feedback off
set echo off
spool schema_ddl.sql
SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name,u.owner) FROM DBA_TABLES u;
SELECT DBMS_METADATA.GET_DDL('VIEW',u.view_name,u.owner) FROM DBA_VIEWS u;
SELECT DBMS_METADATA.GET_DDL('INDEX',u.index_name,u.owner) FROM DBA_INDEXES u;
select dbms_metadata.get_ddl('PROCEDURE',u.object_name, u.owner) from dba_objects u where u.object_type = 'PROCEDURE';
select dbms_metadata.get_ddl('FUNCTION',u.object_name, u.owner) from dba_objects u where u.object_type = 'FUNCTION';
spool off;

select dbms_metadata.get_ddl('TABLESPACE','TBS_NAME') from dual;

select dbms_metadata.get_ddl('USER','EPAY_USER') from dual;

SELECT DBMS_METADATA.GET_DDL('USER',U.username)
FROM DBA_USERS U;

分类:数据库 | 标签: |

相关日志

评论被关闭!