常用SQL语句备忘录

时间:2023-11-23 18:46:50

1.---表中有重复记录用SQL语句查询出来
 select * from Recharge where RechargeSerial in (select RechargeSerial from Recharge group by RechargeSerial having count(*)>1)

2.oracle des加密函数方法

create or replace function encrypt_des(p_text varchar2, p_key varchar2) return varchar2 is
v_text varchar2(4000);
v_enc varchar2(4000);
raw_input RAW(128) ;
key_input RAW(128) ;
decrypted_raw RAW(2048);
begin
v_text := rpad( p_text, (trunc(length(p_text)/8)+1)*8, chr(0));
raw_input := UTL_RAW.CAST_TO_RAW(v_text);
key_input := UTL_RAW.CAST_TO_RAW(p_key);
dbms_obfuscation_toolkit.DESEncrypt(input => raw_input,key => key_input,encrypted_data =>decrypted_raw);
v_enc := rawtohex(decrypted_raw);
dbms_output.put_line(v_enc);
return v_enc; end encrypt_des;

3. 解密函数

create or replace function decrypt_des(p_text varchar2,p_key varchar2) return varchar2 is
v_text varchar2(2000);
begin
dbms_obfuscation_toolkit.DESDECRYPT(input_string => UTL_RAW.CAST_TO_varchar2(p_text),key_string =>p_key, decrypted_string=> v_text);
v_text := rtrim(v_text,chr(0));
dbms_output.put_line(v_text);
return v_text; end decrypt_des;

4.负载均衡

jdbc:oracle:thin:@(DESCRIPTION=(failover = on) (enable = broken) (ADDRESS_LIST= (ADDRESS= (PROTOCOL=TCP)(HOST = 192.10.100.01)(PORT=1521))(LOAD_BALANCE = yes)) (CONNECT_DATA=(SERVICE_NAME = testName) (failover_mode = (type=select)(method=basic)(retries = 10)(delay = 5))))

5.

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=yes)(ADDRESS=(PROTOCOL=TCP)(HOST=192.10.100.01)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.10.100.02)(PORT=1521)))(CONNECT_DATA=(SERVER=default)(SERVICE_NAME=testName)))