易截截图软件、单文件、免安装、纯绿色、仅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 JDeveloper 10g Release Download

Oracle JDeveloper 10g Release Download
Oracle JDeveloper 10g (version 9.0.5.1, build 1605) for Windows NT/2000/X, Linux, Solaris, and HP-UX.
http://download.oracle.com/otn/java/jdeveloper/905/jdev9051.zip
http://download-east.oracle.com/otn/java/jdeveloper/905/jdev9051.zip
http://download-west ......

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游标

ORACLE游标
游标:容器,存放当前SQL语句影响的记录
       所有DML语句都会用到游标
      
       逐行处理影响的行数
 
游标
       静态游标:游标与SQL语句在运行前关联
&nb ......

ORACLE过程、函数

过程、函数
 
 
 
create or replace procedure p1
is
  empname emp.ename%type;
begin
  select ename into empname from emp where empno=7788;
  dbms_output.put_line(empname);
end;
 
SQL> ed
SQL> /
 
Procedure created
 
SQL> exec p1; ......

Oracle DBA日常sql列表及常用视图

不错的资料,转过来,方便日后查看使用!!!
--监控索引是否使用
alter index &index_name monitoring usage;
alter index &index_name nomonitoring usage;
select * from v$object_usage where index_name =
&index_name;
--求数据文件的I/O分布
select
df.name,phyrds,phywrts,phyblkrd,phyblkwrt,sin ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号