百度
360搜索
搜狗搜索

oracle update,oracle视图可以update吗详细介绍

本文目录一览: oracle中update时间的用法

UPDATE FP_DEFP_XX SET RKBS = 1, TimeTamp = '2013800129', RKSJ =to_date('2015/6/17 15:28:59','yyyy-MM-dd hh24:Mi:ss') WHERE GHID = '210D934F88E3409C806874635C44EAD2'
oracle中update时间需要将时间类型进行转换,再去update。
如emp表中有如下数据:
现将empno为7369的hiredate改成1980年1月1日,语句如下:
update emp set hiredate=to_date('1980-01-01','yyyy-mm-dd') where empno=7369;修改后结果为:

oracle update 多个字段更新性能

在 Oracle 数据库中,当需要同时更新多个字段时,可以采用以下方法来提高性能:
1.使用单条 SQL 语句更新多个字段:通过一条 SQL 语句同时更新多个字段可以减少数据库服务器和客户端之间的通信量,从而提高性能。示例语句如下:
UPDATE table_name SET column1=value1,column2=value2,column3=value3 WHERE condition;
2.使用索引:在更新多个字段时,如果表中存在索引,可以加快更新的速度。需要根据具体情况考虑选择合适的索引方式。
3.避免在更新过程中触发触发器:在更新多个字段时,如果表中存在触发器,可以考虑暂时禁用触发器,从而避免在更新过程中不必要的触发器操作,提高性能。
4.使用合适的批量操作方式:当需要更新多条记录时,可以使用批量操作方式,一次性更新多条记录,从而提高性能。示例语句如下:
UPDATE table_name SET column1=value1,column2=value2,column3=value3 WHERE id IN (1,2,3,4,5);
5.优化 SQL 语句:在更新多个字段时,需要优化 SQL 语句,避免使用不必要的子查询和多余的条件,从而减少数据库的负担,提高性能。
需要注意的是,在更新多个字段时,要根据具体情况选择合适的方式,合理利用索引和缓存等机制,避免不必要的数据库操作,从而提高更新性能。

ORACLE大数据表Update处理

  ORACLE中如果表数据量很大(M级或更大) update某个字段是很慢的(如我的HIS项目中更新历史业务流程表 万条记录 用CURSOR来更新 条MIT一次 花了 天也没更新完) 后来尝试过的改进办法有
   把表上的LOGGING取消
   把表上的INDEX取消
  但是依然很慢 无奈下找到这个
  

  在这个主题问答里 ORA官方提了一种处理的办法
   利用CREATE table as select xxxxx的办法来生成一新表T
   在T 上创建与目标表一样的索引
   把目标表删除或RENAME(注意备份以备反悔)
   把T 改名成目标表
  试了一下 果然非常地快 我的任务差不多在 Min就完成了
  如csywdk table_room是一张大表 要删除其中bakfwid在noNewYWFW 中的记录 且要更新bakfwid在imp_table_room中记录的ROOM_LOC为imp_table_room room_loc:
  ( )创建新表
  create table tmp_new_table_room as
  select t ROOM_ID t NEWROOMID t BUILDID t TFH t DKH t BUILD_NO t LAYER_NO t ROOM_NO t ROOM_NAME
  decode(t bakfwid null t ROOM_LOC t room_loc)
  t ROOM_AREA
  t SURTYPE t LAYER_NAME t DEVDEP t CELL t DELFLAG t QXXZ t SJSJLSH t FD t ID t BAKFWID
  from csywdk table_room t left join imp_table_room t on t bakfwid=t bakfwid
  where not exists(select from noNewYWFW t where t bakfwid=t bakfwid)
  ( )创建备份表
  create table Table_room as
  select * from csywdk table_room
  ( )替换原表
  drop table sde table_room
  create table sde table_room as
  select * from tmp_new_table_room
  在这个问答里还提到一句ORA PL/SQL效率相关的话
   能用一句语句处理的任务决不要用多句编程来实现
lishixinzhi/Article/program/Oracle/201311/18980

ORACLE多表关联UPDATE语句

  为了方便起见 建立了以下简单模型 和构造了部分测试数据:
  在某个业务受理子系统BSS中
   客户资料表
  create table customers
  (

  customer_id number( ) not null 客户标示
  city_name varchar ( ) not null 所在城市
  customer_type char( ) not null 客户类型
  
  )
  create unique index PK_customers on customers (customer_id)
  由于某些原因 客户所在城市这个信息并不什么准确 但是在
  客户服务部的CRM子系统中 通过主动服务获取了部分客户 %的所在
  城市等准确信息 于是你将该部分信息提取至一张临时表中
  create table tmp_cust_city
  (
  customer_id number( ) not null
  citye_name varchar ( ) not null
  customer_type char( ) not null
  )
   ) 最简单的形式
   经确认customers表中所有customer_id小于 均为 北京
   以内的均是公司走向全国之前的本城市的老客户:)
  update customers
  set city_name= 北京
  where customer_id<
   ) 两表(多表)关联update 仅在where字句中的连接
   这次提取的数据都是VIP 且包括新增的 所以顺便更新客户类别
  update customers a 使用别名
  set customer_type= 为vip 为普通
  where exists (select
  from tmp_cust_city b
  where b customer_id=a customer_id
  )
   ) 两表(多表)关联update 被修改值由另一个表运算而来
  update customers a 使用别名
  set city_name=(select b city_name from tmp_cust_city b where b customer_id=a customer_id)
  where exists (select
  from tmp_cust_city b
  where b customer_id=a customer_id
  )
   update 超过 个值
  update customers a 使用别名
  set (city_name customer_type)=(select b city_name b customer_type
  from tmp_cust_city b
  where b customer_id=a customer_id)
  where exists (select
  from tmp_cust_city b
  where b customer_id=a customer_id
  )
  注意在这个语句中
  =(select b city_name b customer_type
  from tmp_cust_city b
  where b customer_id=a customer_id
  )
  与
  (select
  from tmp_cust_city b
  where b customer_id=a customer_id
  )
  是两个独立的子查询 查看执行计划可知 对b表/索引扫描了 篇
  如果舍弃where条件 则默认对A表进行全表
  更新 但由于(select b city_name from tmp_cust_city b where where b customer_id=a customer_id)
  有可能不能提供 足够多 值 因为tmp_cust_city只是一部分客户的信息
  所以报错(如果指定的列 city_name可以为NULL则另当别论)
   cannot update (%s) to NULL
  // *Cause:
  // *Action:
  一个替代的方法可以采用
  update customers a 使用别名
  set city_name=nvl((select b city_name from tmp_cust_city b where b customer_id=a customer_id) a city_name)
  或者
  set city_name=nvl((select b city_name from tmp_cust_city b where b customer_id=a customer_id) 未知 )
   当然这不符合业务逻辑了
   ) 上述 )在一些情况下 因为B表的纪录只有A表的 %的纪录数
  考虑A表使用INDEX的情况 使用cursor也许会比关联update带来更好的性能
  set serveroutput on
  declare
  cursor city_cur is
  select customer_id city_name
  from tmp_cust_city
  order by customer_id;
  begin
  for my_cur in city_cur loop
  update customers
  set city_name=my_cur city_name
  where customer_id=my_cur customer_id;
  /** 此处也可以单条/分批次提交 避免锁表情况 **/
   if mod(city_cur%rowcount )= then
   dbms_output put_line( );
   mit;
   end if;
  end loop;
  end;
   ) 关联update的一个特例以及性能再探讨
  在oracle的update语句语法中 除了可以update表之外 也可以是视图 所以有以下 个特例
  update (select a city_name b city_name as new_name
  from customers a
  tmp_cust_city b
  where b customer_id=a customer_id
  )
  set city_name=new_name
  这样能避免对B表或其索引的 次扫描 但前提是 A(customer_id) b(customer_id)必需是unique index
  或primary key 否则报错
   cannot modify a column which maps to a non key preserved table
  // *Cause: An attempt was made to insert or update columns of a join view which
  // map to a non key preserved table
  // *Action: Modify the underlying base tables directly
   )oracle另一个常见错误
  回到 )情况 由于某些原因 tmp_cust_city customer_id 不是唯一index/primary key
  update customers a 使用别名
  set city_name=(select b city_name from tmp_cust_city b where b customer_id=a customer_id)
  where exists (select
  from tmp_cust_city b
  where b customer_id=a customer_id
  )
  当对于一个给定的a customer_id
  (select b city_name from tmp_cust_city b where b customer_id=a customer_id)
  返回多余 条的情况 则会报如下错误
   single row subquery returns more than one row
  // *Cause:
  // *Action:
  一个比较简单近似于不负责任的做法是
  update customers a 使用别名
  set city_name=(select b city_name from tmp_cust_city b where b customer_id=a customer_id and rownum= )
  如何理解 错误 在一个很复杂的多表连接update的语句 经常因考虑不周 出现这个错误
  仍已上述例子来描述 一个比较简便的方法就是将A表代入 值表达式 中 使用group by 和
  having 字句查看重复的纪录
  (select b customer_id b city_name count(*)
  from tmp_cust_city b customers a
  where b customer_id=a customer_id
  group by b customer_id b city_name
  having count(*)>=
lishixinzhi/Article/program/Oracle/201311/18909

阅读更多 >>>  关系型数据库管理系统有哪些,目前流行的DBMS有哪些?

oracle视图可以update吗

不可以。update对表起作用。需要update视图所查询的表。
可以的
这个视图只能是单表视图
可以的
直接更新视图中的数据可以更新其对应的基础数据表
并非视图中的所有数据都可以更新到基础数据表,只有那些直接从基础数据表获得的数据可以被更新
视图中的虚列不可以被更新,虚列是指通过运算获得,基础数据表中并不存在的列
比如基础数据表有tb_employees, tb_sales两个,我们创建一个view:
create or replace view vw_employee_salary as select e.emp_name employee, e.emp_salary+s.sales_totalprice*0.1 salary from dt_employees e, dt_sales s where e.id=s.sales_by此时,视图中的employee列可以更新,而salary 列是虚列,不可以更新

oracle中怎么update(更新)date型的数据

数据类型不同,一个是字符串类型,一个是日期类型
强制转制一下类型试试
update tranbill set odate='"+Convert.ToDateTime(“2010-12-14”)+"' where bcode='0409'
不知道行不行,我没试过
update tranbill set odate=to_date('20101214','yyyymmdd') where bcode='0409'
1、创建测试表,
create table test_date(id number, value date);
2、插入测试数据
insert into test_date values(1,sysdate);
insert into test_date values(2,sysdate-100);
insert into test_date values(3,sysdate-55);
commit;
3、查询表中全量数据,select t.*, rowid from test_date t;
4、编写sql,更新date类型的value字段值为:2010-12-14;
update test_date set value = to_date('2010-12-14','yyyy-mm-dd') where id = 3;
commit;

5、再次查询sql,可以发现id为3的value值已变化; select t.*, rowid from test_date t;

oracle 批量update进行判断

使用oracle进行批量update更新数据的时候,可以在更新前进行判断,根据条件进行批量更新
update tables_name t
set t.value1 = case
when t.value1 = '33020' then
'330200'
when t.value1 = '33021' then
'330210'
when t.value1 = '33022' then
'330221'
end
where t.value1 in ('33020', '33021', '33022');

oracle几百万条数据怎么update

首先要区分具体情况,虽然表里有几百万几千万的数据量,但是update是同时update这几百万条的数据呢?还是只更新其中某几条? 更新的数据量不同,解决方案自然也就有差异。同时update几百万数据,这个sql的性能影响在于数据库会做回滚段,以便异常时rollback。由于数据量大,性能就浪费在回滚段上了。 所以有2个方案供参考:
1. update时 ,禁用回滚段的生成,跟你前面说的nologing应该是一个意思
2. 分批更新,比如每更新10W条数据,就执行一次commit,这样效率也会比原来的要快。

oracle 数据库用update 语句更新无效。

你这问题也太。。。。内容呢?sql语句呢?错误信息呢?
如果按你说的无效的话,可能是你没有commit,所以导致你更新以后没有提交到数据库中。你再次查询的时候仍然是你之前的数据
同意楼下,可能是没有提交事务。没有提交事务的话,数据库是不会更新的。
1、若是执行完sql后没有commit,执行结果不会保存,所以update语句无效;
2、若是执行了commit,update仍然没有生效,说明表空间可能存在问题,需要具体排查,当然最直接的是删除表空间,重新建立

oracle如何批量update

参考一下这个方式
UPDATE
TAB_1 t1
SET
(
t1.f1
,t1.f2
) =
(SELECT
t2.f1
,t2.f2
FROM TAB_2 t2
WHERE t1.f1 = t2.f2
AND t1.f2 = t2.f2
AND t1.f3 = t2.f3
)
WHERE EXISTS (SELECT 1
FROM TSRCREW.WK_UBH0200Z t2
WHERE t1.f1 = t2.f1
AND t1.f2 = t2.f2
AND t1.f3 = t2.f3);

网站数据信息

"oracle update,oracle视图可以update吗"浏览人数已经达到25次,如你需要查询该站的相关权重信息,可以点击进入"Chinaz数据" 查询。更多网站价值评估因素如:oracle update,oracle视图可以update吗的访问速度、搜索引擎收录以及索引量、用户体验等。 要评估一个站的价值,最主要还是需要根据您自身的需求,如网站IP、PV、跳出率等!