有表:
name fenshu
张三 89
李四 92
王五 79
现想插入一列,变为:
name fenshu age
张三 89 18
李四 92 17
王五 79 17
插入的这一列可以通过select语句从另外的表中得到,
本人刚学sql语句,只知道insert是插入行,不知道怎样插入列,
请各位不吝赐教!
name fenshu
张三 89
李四 92
王五 79
现想插入一列,变为:
name fenshu age
张三 89 18
李四 92 17
王五 79 17
插入的这一列可以通过select语句从另外的表中得到,
本人刚学sql语句,只知道insert是插入行,不知道怎样插入列,
请各位不吝赐教!
解决方案 »
- 超级菜鸟问题:如何执行这个script block?
- 问个弱弱的问题。。。
- 各位大虾帮帮忙,在pl/sql developer中下列需求如何实现???????????????
- 救命求助!我正要做ORACLE的OAS项目,谁能提供OAS WEB服务器的详细配置资料?万分感谢
- 关于facth的一个无理要求,请指教
- sql问题,大伙看看先!
- 求救ORA-12570:TNS:包阅读程序失败
- 在vsphere中,作为oracle 10g rac节点的两台虚拟机,每做快照都会自动重启
- 求助sql问题,在线等,急!!!
- 搭建数仓抽取数据过程中,kettle提示表空间不足,请问怎么解决?中途停止建立的数据文件,offline drop后并手动删除了dbf文件后会有什么影响?
- 在线求救 解决了马上给分!!!
- 求一条查询语句
update 表1 set age=(select age from 表2 where 表1.字段1=表2.字段1)
where exists(select 1 from 表2 where 表1.字段1=表2.字段1)
然后再插入数据:update table_name set age=18 where name='张三';
update table_name set age=17 where name='李四';
update table_name set age=17 where name='王五';
drop table 表1
create table 表1 as select col1,col2,col3 from 表2 where ...
表2里只有age这个字段,没有前两列,所以上面的好像不行
create view v_name as select a.name,a.fenshu,b.age from table_1 a,table_b where
或者把view改成table,然后把原来的table删掉,把现在的v_name 改名成原来的table就可以了
alter talbe tableName add age number(3);
2.update table1 set age=(select ......)
update 目标表 a
set age = (select age from 源表 b where a.字段=b.字段)
where exists (select 1 from 源表 b where a.字段=b.字段)
update table a
set age=(select age from table b where a.字段=b.字段)
where exists (select 1 from table b where a.字段=b.字段)