UPDATE TABLENAME SET NO =REPLACE ( NO , 'id' , 'no' ) ;
再问一下, 如果我的no也是选出来的,如: select no from table1 where ......那这个题目除了写成: update table1 set no=replace(no,'id','no') where ... 可以这么写吗: update table1 set (select no from table1 where ......)--我想写成这种结构的,不知道怎么写 = replace(no,'id','no')
该学习基本的sql知识了! update table1 set no=replace(no,'id','no') where ...;
update table1 set no=replace(no,'id','no') where....
See this:SQL*Plus: Release 9.2.0.1.0 - Production on 星期四 7月 31 16:11:43 2008Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. 连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining optionsSQL> select * from test1; A B ---------- ---------- 11 22 12 23 13 24 14 34 15 23SQL> desc test1; 名称 是否为空? 类型 ----------------------------------------- -------- ---------------------------- A NUMBER(38) B NUMBER(38)SQL> alter table test1 add name varchar2(10);表已更改。SQL> desc test1; 名称 是否为空? 类型 ----------------------------------------- -------- ---------------------------- A NUMBER(38) B NUMBER(38) NAME VARCHAR2(10)SQL> update test1 set name=test1.A||'id';已更新5行。SQL> select * from test1; A B NAME ---------- ---------- -------------------- 11 22 11id 12 23 12id 13 24 13id 14 34 14id 15 23 15id SQL> update test1 set name=replace(name,'id','no');已更新5行。SQL> select * from test1; A B NAME ---------- ---------- -------------------- 11 22 11no 12 23 12no 13 24 13no 14 34 14no 15 23 15noSQL> update test1 set name=replace(name,'no','id') where A in (11,12,13);已更新3行。SQL> select * from test1; A B NAME ---------- ---------- -------------------- 11 22 11id 12 23 12id 13 24 13id 14 34 14no 15 23 15no
update table1 set no=replace(no,'id','no')
TABLENAME SET NO =REPLACE ( NO ,
'id' ,
'no' ) ;
如果我的no也是选出来的,如:
select no
from table1
where ......那这个题目除了写成:
update table1 set no=replace(no,'id','no') where ...
可以这么写吗:
update table1 set
(select no from table1 where ......)--我想写成这种结构的,不知道怎么写
=
replace(no,'id','no')
该学习基本的sql知识了!
update table1 set no=replace(no,'id','no') where ...;
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining optionsSQL> select * from test1; A B
---------- ----------
11 22
12 23
13 24
14 34
15 23SQL> desc test1;
名称 是否为空? 类型
----------------------------------------- -------- ----------------------------
A NUMBER(38)
B NUMBER(38)SQL> alter table test1 add name varchar2(10);表已更改。SQL> desc test1;
名称 是否为空? 类型
----------------------------------------- -------- ----------------------------
A NUMBER(38)
B NUMBER(38)
NAME VARCHAR2(10)SQL> update test1 set name=test1.A||'id';已更新5行。SQL> select * from test1; A B NAME
---------- ---------- --------------------
11 22 11id
12 23 12id
13 24 13id
14 34 14id
15 23 15id
SQL> update test1 set name=replace(name,'id','no');已更新5行。SQL> select * from test1; A B NAME
---------- ---------- --------------------
11 22 11no
12 23 12no
13 24 13no
14 34 14no
15 23 15noSQL> update test1 set name=replace(name,'no','id') where A in (11,12,13);已更新3行。SQL> select * from test1; A B NAME
---------- ---------- --------------------
11 22 11id
12 23 12id
13 24 13id
14 34 14no
15 23 15no