数据库两张表关联更新以及随机序号生产

UPDATE T_CMP_INVESTMENT SET F_INVESTED_DATE = (SELECT F_PARNTER_SUBSCRIBE_DATE FROM T_CMP_PARNTNER WHERE T_CMP_PARNTNER.F_PARNTNER_NAME=T_CMP_INVESTMENT.F_COMPANY_NAME);

SELECT F_PARNTER_SUBSCRIBE_DATE FROM T_CMP_PARNTNER LEFT JOIN T_CMP_INVESTMENT ON T_CMP_PARNTNER.F_PARNTNER_NAME=T_CMP_INVESTMENT.F_COMPANY_NAME

WHERE T_CMP_PARNTNER.F_PARNTNER_NAME=T_CMP_INVESTMENT.F_COMPANY_NAME

UPDATE (SELECT F_INVESTED_DATE,F_PARNTER_SUBSCRIBE_DATE FROM T_CMP_PARNTNER LEFT JOIN T_CMP_INVESTMENT ON T_CMP_PARNTNER.F_PARNTNER_NAME=T_CMP_INVESTMENT.F_COMPANY_NAME)

SET F_INVESTED_DATE = F_PARNTER_SUBSCRIBE_DATE

SELECT * FROM T_CMP_PARNTNER WHERE F_PARNTNER_ID IS NULL

select * from (

SELECT DISTINCT F_PARNTNER_ID,COUNT(1) AS CNT FROM  T_CMP_PARNTNER

GROUP BY F_PARNTNER_ID )

where cnt >1       //显示表内具有相同F_PARNTNER_ID的数量,主要用来判断id的唯一性

select dbms_random from T_CMP_PARNTNER

where F_PARNTNER_ID = 'e2484e06072ca6eab6633cdd3fdbd7b4'

select rawtohex(sys_guid()) from dual

update T_CMP_PARNTNER

set F_PARNTNER_ID = rawtohex(sys_guid())    //sys_guid()用随机数生成id,确定存在即唯一!!!rawtohex是用来二进制转换,防止乱码

你可能感兴趣的:(数据库两张表关联更新以及随机序号生产)