1. 创建表
create table test_ty( id integer not null primary key, name varchar2(40) not null, passwd varchar2(56) not null);
2. 创建函数
CREATE OR REPLACE FUNCTION MD5 ( p_str in varchar2) RETURN varchar2 IS BEGIN RETURN Utl_Raw.Cast_To_Raw(DBMS_OBFUSCATION_TOOLKIT.MD5(input_string => Upper(P_Str))); END;
3. 修改表
alter table test_ty modify column (passwd varchar2(32) not null);
4. 创建函数
create sequence test_ty_sequence increment by 1 start with 1 nomaxvalue nocycle cache 10;
5. 创建存储过程
create or replace procedure insert_test_ty(p_name in varchar2, p_passwd in varchar2) is begin insert into test_ty(id, name, passwd) values (test_ty_sequence.nextval, p_name, MD5(p_passwd); end;
6. 调用存储过程
call insert_test_ty('smith', '841021');