Oracle使用总结一
一、修改表名要修改索引以及主键
ALTER TABLE AFA_AUTH_FUNCTION RENAME TO BACK_AFA_AUTH_FUNCTION ----修改表名
alter table BACK_AFA_AUTH_FUNCTION rename constraint PK_AFA_AUTH_FUNCTION to PK_BACK_AFA_AUTH_FUNCTION; ----修改主键
alter index PK_AFA_AUTH_FUNCTION rename to PK_BACK_AFA_AUTH_FUNCTION; ----修改索引
在做不同系统的集成时,有的表重复了,又不想删除,这时候就可以修改相应的表名、主键名、索引名
二、Case-When用法
update afa_auth_role set FSUBSYSTEMID=
(case
when FSUBSYSTEMID = 'c08af79072f444878c7c5deea25187aa' then
'NONTAX-PLATFROM'
when FSUBSYSTEMID = '896a7961034b4559b4fc4a1520460075' then
'NONTAX-BASE'
when FSUBSYSTEMID = '8c36fdbdce80424a9ae3f11183e19f47' then
'NONTAX-AGENCY'
when FSUBSYSTEMID = '0816b0670e7d428d886e54e7fc0fcb5a' then
'NONTAX-FINANCE'
end);
注意相关的写法。
三、insert 与时间行数等配合使用
Insert into afa_org (ORG_ID, ORG_CODE, ORG_NAME, PARENT_ORG_ID, ORG_LEVEL, IS_LEAF, ORG_TYPE, STATUS, CREATE_TIME, LASTEST_TIME)
select t.fid as ORG_ID,
t.ffindeptcode as ORG_CODE,
t.ffindeptname as ORG_NAME,
t.frgnid as PARENT_ORG_ID,
null as ORG_LEVEL,
null as IS_LEAF,
'FINDEPT' as ORG_TYPE,
t.fisenable as STATUS,
to_date(t.fcreatetime,'yyyy-mm-dd hh24:mi:ss') as CREATE_TIME,
to_date(TO_CHAR(to_timestamp(t.fupdatetime, 'yyyymmddhh24missff3'),
'yyyy-mm-dd hh24:mi:ss'),
'yyyy-mm-dd hh24:mi:ss') as LASTEST_TIME from fab_fin_dept t;
注意相关函数的配合使用。
四、相关技巧
select (t4.fcode || '_' || t3.fcode) as PARTY_CODE
通过||可以将两个字段合并
update afa_app_function set func_seq= (APP_ID ||func_seq) where APP_ID<>'APPCENTER';
<>不等于标志