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 ......
在sql语句中涉及到时间类型时 若只想要日期 to_date('2007-7-8','yyyy-mm-dd')
在C#中有datetime类型,代码说明一切
DateTime dt = System.DateTime.Now;
string lsh;
lsh=string.Format("{0:yyyyMMddHHmmss}", dt);
DateTime dt = DateTime.Now;
Label1.Text = dt.To ......
在开发应用的时候,把数据按照一定的规则排序后再取前几条数据这种操作是很平常的事情。我们在Oracle中常用的就是order by,然后取得rownum小于多少的数据这种方法。不过如果对Oracle不熟悉,也许就会发现你写的SQL语句检索出来的值不正确,这个是为什么呢。 因为Oracle在检索的时候,会首先把数据都检索出来,然后在排序段 ......
开窗函数的的理解:
开窗函数指定了分析函数工作的数据窗口大小,这个数据窗口大小可能会随着行的变化而变化,举例如下:
over(order by salary) 按照salary排序进行累计,order by是个默认的开窗函数
over(partition by deptno)按照部门分区
ove ......
我们初学者安装oracle的时候,字符集选择的一般是简体中文的格式,这方便我们英文不好的菜鸟,出错的时候定位错误,但是有一个问题伴随出现,我们写关于日期的sql的语句,我们想要英文的格式怎么办?下面有两个办法:
1. 连接到数据库后,我们使用如下语句
ALTER SESSION SET NLS_D ......