打不死的心态活到老。

数据库应用一

上一篇 / 下一篇  2007-08-02 15:27:04 / 个人分类:数据库

)I`9cz`0来源于网络

sR7Zj;G a051Testing软件测试网#`J+M k e rK

51Testing软件测试网i)n.Xhi/a{0f
1* select ename from emp51Testing软件测试网t!d1lv#^4C/m
11:07:20 SCOTT > /
[~8n&lP,Yc r1BS/?0SMITH_test
M:~ o%N'h T h0ALLEN_test
CS F&g2P uF0WARD_test
R"dz7K c|0JONES_test
zm$vR,]8L2fD0MARTIN_test
^_%u6pE0BLAKE_test51Testing软件测试网7C3L7b x;P-I4l/SR{
CLARK_test51Testing软件测试网o2M?R-b+\
SCOTT_test51Testing软件测试网#NX|j*M9W
KING_test
Ms w['^+C2k6p0TURNER_test
`4{\N3o _0ADAMS_test
Zj ijrm m0JAMES_test51Testing软件测试网5u0\#p Jl X
FORD_test51Testing软件测试网|~dLn2m
MILLER_test51Testing软件测试网 XT-s[V]_1AGC

51Testing软件测试网{$Mbf+u4L{,YU

emp表中的ename栏位所有记录后都有_test,如何去除所有记录中的后5位 “_test”51Testing软件测试网 bX^po
使它们变成51Testing软件测试网zD|%f*b:w
SMITH51Testing软件测试网8Om.dpF-L`_
ALLEN
D(SY"d6I t0WARD51Testing软件测试网(w%\]A_c0m

N*^-[;S5OEC0方法一:51Testing软件测试网I,z.{7L#Na$g"q$l
select rtrim(ename, '_test') from emp

m&pV%b)za_f051Testing软件测试网$K4|J]h

(不能处理'a_test_test'的情况)

^ V:r!QkB0

1o.GV7Ote0方法二:51Testing软件测试网X0e"f#Q2B ~*Y+v
select reverse(substr(reverse('1234_test'), 6)) as val from dual;

n.Lc.~.J(N W$uP h051Testing软件测试网']f|.Lz |

方法三:51Testing软件测试网4q,S"J`-K4N
SQL> select * from test;

-^V@/Ra1z1y051Testing软件测试网o3a/xn1GGl:P

NAME
-[9@7ie7l!_"D0----------51Testing软件测试网!?5s/Je,jW(a^
ALLEN_test51Testing软件测试网4D8`6T{$vlb9y*|9Fo
WARD_test
3AZ-iE:vC w0TU_test

2x b1L%P.l8]051Testing软件测试网2L3R+|]\~d9ti

SQL> update test set name= substr(name,1,length(name)-5) ;51Testing软件测试网A;Cs6T-@~O

51Testing软件测试网*to!^(Hk&Z6y?

已更新3行。

Xz f$h6^ ]]8q0

q? Rw'usI0SQL> select * from test;51Testing软件测试网/w.R0H3? H

51Testing软件测试网3d3Ggmr \3siL:C"B

NAME
(S_ C7T5ss)?z%^n0----------
F)SF:Jx8rN0ALLEN
-@dc8?%]:^6e.T0WARD51Testing软件测试网ne:db4Z.f~*Z
TU51Testing软件测试网o[.[&?YS%@

51Testing软件测试网 b1H?G kS]f

SQL>

gqF j(OW r'n5M051Testing软件测试网Jb*po PtT

 

3r3I Mu5I7R }@0

;])y0BVIr)N)V#_6~"F0 

,z:r!?1U%oD4B*?&c0

TAG: 数据库

 

评分:0

我来说两句

Open Toolbar