易截截图软件、单文件、免安装、纯绿色、仅160KB

oracle PK问题

我列出我全部的做法:

table a 有id1, str1, str2, str3


开始的pk是id1, str1, str2
希望改成id1, str1, str3
--问题
小弟先有如下问题:

一个表原来的PK是 id1+str1+str2 列
先修改成id1+str1+str3列
而这三列现在当前数据库的数据有重复的情况, 小弟现在用sql:
ALTER table a add
 
constraint PK_a primary key (id1,str1,str3) 
    USING INDEX
TABLESPACE ts
      ENABLE NOVALIDATE;


但是还是提示会出错,哪位大虾给帮忙一下~~
急啊!在线等!!!!
我的步骤:

Alter table a drop primary key drop index;
ALTER table a add
 
constraint PK_a primary key (id1, str1, str3) 
    USING INDEX
TABLESPACE ts
      ENABLE NOVALIDATE;
提示的错误:
SQL>
ALTER table evanpk add
  2    constraint PK_evanpk primary key
(id1, str1, str2) 
    USING INDEX TABLESPACE WBXOBJ_LARGE_IDX
  3    4        ENABLE NOVALIDATE;
  constraint PK_evanpk primary
key (id1, str1, str2)
            *
ERROR at line 2:

ORA-02437: cannot validate (TEST.PK_EVANPK) - primary key violated
回答----原因分析
SQL> create table t1(c1 number,c2 varchar2(10));

表已创建。

SQL> insert into t1 values(1,1);

已创建 1 行。

SQL> insert into t1 values(1,2);

已创建 1 行。


SQL> alter table t1 add constraint pk_t1 primary key(c1) enable
novalidate;
alter table t1 add constraint pk_t1 primary key(c1)
enable novalidate
                              *
第 1 行出现错误:
ORA-02437: 无法验证 (TEST.PK_T1) - 违反主键


SQL> create
index idx_t1 on t1(c1);

索引已创建。

SQL> alter table
t1 add constraint pk_t1 primary key(c1) using index idx_t1 enab
le
novalidate;

表已更改。


相关文档:

ORACLE 分组 排序出前面最大的N行

select  custid,carid,Cunote,INVNO,BUYPLAN  
from ( select custid,carid,Cunote,INVNO,BUYPLAN,
row_number() over(partition by custid,carid order by Feedbackid desc) rn
  from pvE3S.T_VCTM_CUSTOMER_FEEDBACK) t1 where rn=1
按Feedbackid 排序,rn是前N行 ......

RedHat Linux安装Oracle10g(图文详解 教程)

RedHat Linux安装Oracle10g(图文详解 教程)
http://winie.javaeye.com/blog/405120
关键字: redhat linux安装oracle10g(图文详解 教程)

另,本人有Word电子文档格式,如需要,请联系本人:asima127@gmail.com
  
1     
安装RedHat Enterprise Linux 3 ......

Two papers on Oracle 11g Security

Hey all,
Since there seems to be a fair bit of disinformation, and utter nonsense,
floating around since my talk at the Black Hat Federal security conference
the other day, I have decided to publish the following papers.
http://www.databasesecurity.com/HackingAurora.pdf
http://www.databasesec ......

Oracle SQL PLUS 登录 启动 关闭


Oracle SQL PLUS 基本操作1
登录
c:\>sqlplus "sys/test1234 as sysdba"  以sysdba身份登录
 
c:\>sqlplus/nolog   以nolog身份登录
sql> connect sys/test1234 as sysdba
Connected.
 
 
启动 
SQL>  startup    &nb ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号