操作:
專(zhuān)注于為中小企業(yè)提供網(wǎng)站建設(shè)、網(wǎng)站制作服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)章丘免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上千多家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
1、先在Excel中將這一列值加前綴,將 user_code的值變成字符型,如原來(lái)的001,002變成N001,N002,
2、將變后的Excel表導(dǎo)入到Oracle中,
3、用Uperdate 語(yǔ)句修改user_code列,去掉前綴字母“N”。
如果字符串只有開(kāi)頭有零,而字符串中間沒(méi)有0,那么可以使用replace(字符串,'0','')
如果0開(kāi)頭最長(zhǎng)的位數(shù)不長(zhǎng),那么可以逐個(gè)判斷。
比如我可能知道這里面最長(zhǎng)的就是連續(xù)5個(gè)0開(kāi)頭的,這樣我就判斷如果遇到5個(gè)0開(kāi)頭的就截掉前五位,4個(gè)0開(kāi)頭截掉前四位,3個(gè)0開(kāi)頭截掉前三位,一直到1,逐個(gè)判斷使用case when可以完成.但是如果最長(zhǎng)的0開(kāi)頭個(gè)數(shù)不確定,就比較麻煩了。
其實(shí)我覺(jué)得這種情況做個(gè)試驗(yàn)最好了,自己建個(gè)分區(qū)表,然后把每個(gè)分區(qū)建的小一點(diǎn),分別插入數(shù)據(jù)看哪個(gè)分區(qū)的數(shù)據(jù)比較大就可以了 。
create table temp1
(month1 integer,
column1 varchar2(10))
PARTITION BY LIST ("MONTH1")
(PARTITION "M11" VALUES (201011)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOLOGGING
STORAGE(INITIAL 1024 NEXT 1024 MINEXTENTS 1 MAXEXTENTS 5242880
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) , PARTITION "M12" VALUES (201012)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOLOGGING
STORAGE(INITIAL 1024 NEXT 1024 MINEXTENTS 1 MAXEXTENTS 5242880
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
);
insert into temp1
values(201011,'0000000000');
commit;
insert into temp1
values(201012,'0');
commit;
declare i integer;
begin
for i in 1..16
loop
insert into temp1 select * from temp1;
commit;
end loop;
end;
select t.bytes,t.partition_name from dba_segments t where t.SEGMENT_NAME='TEMP1';
結(jié)果應(yīng)該是
2097152 M11
1048576 M12
給你做個(gè)試驗(yàn)?zāi)憔椭懒?/p>
create?table?test
(id?varchar2(6));
insert?into?test?values?('120000');
insert?into?test?values?('120010');
insert?into?test?values?('120200');
insert?into?test?values?('123000');
insert?into?test?values?('123001');
commit;
執(zhí)行第一遍:
update?test?set?id=substr(id,1,5)?where?id?like?'%0';
commit;
此時(shí)結(jié)果:
執(zhí)行第二遍:
update?test?set?id=substr(id,1,4)?where?id?like?'%0';
commit;
后邊就不舉例了,也就是語(yǔ)句執(zhí)行4遍,需要修改里邊的參數(shù)。
select id
from (select id,decode(id,0,0,1) as flag from table_name) t
order by flag desc,id
;
這樣id=0的部分就會(huì)排在最下面
我寫(xiě)一份,你試試,看看能不能通過(guò)一個(gè)SQL就能完成
select t.employee_id employee_id,
t.department_id department_id,
min(t.start_date) date,
min(t.start_date) start_date,
max(t.end_date) end_date,
(select t2.position
from table_name t2
where t2.employee_id = employee_id
and t2.department_id=department_id
and t2.end_date =end_date ) position
from table_name t
group by employee_id,
department_id,
position
網(wǎng)站標(biāo)題:oracle如何去除0,oracle去掉開(kāi)頭零
標(biāo)題網(wǎng)址:http://chinadenli.net/article46/heepeg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、自適應(yīng)網(wǎng)站、電子商務(wù)、建站公司、品牌網(wǎng)站制作、網(wǎng)站內(nèi)鏈
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)