update语句出现
ORA-00001: 违反唯一约束条件 怎么解决?
我是直接输入的update:
update LXWMXXB L set L.LXWMXXB_ID=201208311346401653140,L.LXDW='asdfd',L.LXFS='sdfdf'
建表语句如下,是不是哪里没设置好?
-- Create table
create table LXWMXXB
(
   lxwmxxb_id VARCHAR2(32) not null,
   sj         DATE,
   lxdw       VARCHAR2(50),
   lxfs       VARCHAR2(200)
)
tablespace ZF
   pctfree 10
   initrans 1
   maxtrans 255
   storage
   (
     initial 64K
     minextents 1
     maxextents unlimited
   );
-- Add comments to the table  
comment on table LXWMXXB
   is '联系我们信息表';
-- Add comments to the columns  
comment on column LXWMXXB.lxwmxxb_id
   is '联系我们信息表';
comment on column LXWMXXB.sj
   is '添加时间';
comment on column LXWMXXB.lxdw
   is '联系单位';
comment on column LXWMXXB.lxfs
   is '联系方式';
-- Create/Recreate primary, unique and foreign key constraints  
alter table LXWMXXB
   add constraint PK_LXWMXXB_ID primary key (LXWMXXB_ID)
   using index  
   tablespace ZF
   pctfree 10
   initrans 2
   maxtrans 255
   storage
   (
     initial 64K
     minextents 1
     maxextents unlimited
   );
求解决 谢谢给位了
------解决方案--------------------
LXWMXXB_ID这个是主键,你的记录是否多于一条,多于一条你这样更新肯定有问题,加个where条件,更新表的主键一般不建议这样做
方法1:加个where条件,把你的此列LXWMXXB_ID值都设为唯一的,就可以了
方法2:删除这个主键 alter table LXWMXXB drop constraint PK_LXWMXXB_ID  
方法3:禁用主键检查约束,但一般不这样做 alter table LXWMXXB disable constraint PK_LXWMXXB_ID  
SQL code
update LXWMXXB L set L.LXWMXXB_ID=201208311346401653140
,L.LXDW='asdfd',L.LXFS='sdfdf'
where 你的条件
------解决方案--------------------
update LXWMXXB L set L.LXWMXXB_ID=201208311346401653140,L.LXDW='asdfd',L.LXFS='sdfdf'
没有写WHERE条件