Oracle sql语句把字段中的某个字符去掉

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle sql语句把字段中的某个字符去掉相关的知识,希望对你有一定的参考价值。

参考技术A

1、创建测试表,

create table test_date2(id int , v_date varchar(20));

2、插入测试数据

insert into test_date2 values(1,'2014-01');

insert into test_date2 values(2,'2014-02');

insert into test_date2 values(3,'2014-03');

insert into test_date2 values(4,'2014-04');

insert into test_date2 values(5,'2014-05');

insert into test_date2 values(6,'2014-06');

commit;

3、查询表中数据,可以发现字段中带有字符,'-',select t.* from test_date2 t;

4、编写sql,把字段中的字符‘-’去掉; select t*, replace(v_date,'-','') v_date2 from test_date2;

sql语句把字段中的某个字符去掉

 sql语句把字段中的某个字符去掉

update Notifications set Accessory=replace(Cast(Accessory as varchar(8000)),http://demo.m-school.net,‘‘)

 例如:

update Notifications set Accessory=replace(Cast(Accessory as varchar(8000)),http://192.168.2.180,‘‘)
update Notifications set Accessory=replace(Cast(Accessory as varchar(8000)),http://zpzx.m-school.net,‘‘)
update Homeworks set Accessory=replace(Cast(Accessory as varchar(8000)),http://192.168.2.180,‘‘)
update Homeworks set Accessory=replace(Cast(Accessory as varchar(8000)),http://zpzx.m-school.net,‘‘)
update OpenCourses set Attachment=replace(Cast(Attachment as varchar(8000)),http://192.168.2.180,‘‘)
update OpenCourses set Attachment=replace(Cast(Attachment as varchar(8000)),http://zpzx.m-school.net,‘‘)
update OpenCourses set Audio=replace(Cast(Audio as varchar(8000)),http://192.168.2.180,‘‘)
update OpenCourses set Audio=replace(Cast(Audio as varchar(8000)),http://zpzx.m-school.net,‘‘)
update ListenCourses set Attachment=replace(Cast(Attachment as varchar(8000)),http://192.168.2.180,‘‘)
update ListenCourses set Attachment=replace(Cast(Attachment as varchar(8000)),http://zpzx.m-school.net,‘‘)
update ListenCourses set Audio=replace(Cast(Audio as varchar(8000)),http://192.168.2.180,‘‘)
update ListenCourses set Audio=replace(Cast(Audio as varchar(8000)),http://zpzx.m-school.net,‘‘)

老师,学生,家长头像:

update Sys_User set Portrait=replace(Portrait,http://zpzx.m-school.net,‘‘)
update Students set Portrait=replace(Portrait,http://zpzx.m-school.net,‘‘)
update Parents set Portrait=replace(Portrait,http://zpzx.m-school.net,‘‘)

 

以上是关于Oracle sql语句把字段中的某个字符去掉的主要内容,如果未能解决你的问题,请参考以下文章

在ORACLE中,怎么样取把一个字段去掉最后一位,再分组?

oracle 去掉字符,剩下数字

如何写sql语句去掉oracle返回结果中的空值(NULL)

sqlserver查询字段里面如何去除空格

oracle数据库怎样用SQL语句把字段中所有的字节转化在大写?

oracle如何去除某个字段中两边的空格