Oracle更新多行
更新多行的步骤:
步骤多,但效率比较高:
1、create table 临时表 value (select a.id,a.name,b.name,... from table1 a,table2 b where a.id=b.id)
2、删除table1中的记录,不要drop
3、insert into table1 select 你需要的字段 from 临时表。
select * from tb_ai03
create table tb_ai031 as select * from tb_ai03
delete from tb_ai03 a where a.yymm in ('200911','200910')
insert into tb_ai03
select a.model,a.yysal/b.unitestrip as yysal ,a.mmsal/b.unitestrip as mmsal,
a.yychu/b.unitestrip as yychu,a.mmchu/b.unitestrip as mmchu,a.yymm
from tb_ld04 b,tb_ai031 a
where a.model=b.model(+) and a.yymm in ('200911','200910')
相关文档:
1、下载oracle软件
http://www.oracle.com/technology/software/tech/oci/instantclient/index.html
oracle-instantclient-basic-10.2.0.4-1.i386.rpm
oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm
oracle-instantclient-devel-10.2.0.4-1.i386.rpm
2、安装rpm包
rpm -ivh oracle-instantclient-basic-10.2.0.4 ......
开窗函数的的理解:
开窗函数指定了分析函数工作的数据窗口大小,这个数据窗口大小可能会随着行的变化而变化,举例如下:
over(order by salary) 按照salary排序进行累计,order by是个默认的开窗函数
over(partition by deptno)按照部门分区
ove ......
我们在创建表结构的过程中,可能会由于失误,造成表中列名错误,如何更改呢,你可能会回答,使用OEM或者PL/SQL,除了这两种方法,我们可以使用命令:
ALTER TABLE 表名 rename column 列名 to 新列名 注意column是关键字 /*重命名列名*/
ALTE ......
对于我们刚入门的oracle初学者来说,学习sql语言是入门的第一步,面对单引号和双引号,我们可能会困惑,什么时候用单引号,什么时候用双引号呢?
单引号------ 值为字符和日期的时候 如 'you' '06-june' 还有使用连接符||,插入空格||' ......