Constraint primary key turn off - turn on problem solution
Hellorecently I truncate a table. during the truncation process I face with problem and solve below the track.
SQL > TRUNCATE TABLE USER_STATE;
TRUNCATE TABLE USER_STATE
*
ERROR on line 1:
ORA-02266: permit to unique/primary keys in table referenced by foreign keys
Then I find the related CONSTRAINT on the table according to the truncate table ORA-02266
SQL > ALTER TABLE USER_STATE_PARAMETER disable the CONSTRAINT FK1_USR_SES_ST_PAR;
Modified table.
SQL > ALTER TABLE USER_STATE disable the CONSTRAINT SYS_C0030849;
Modified table.
Then successfully truncate the table as below
SQL > TRUNCATE TABLE USER_STATE;
Table truncated.
then I activate the CONSTRAINT
SQL > ALTER TABLE USER_STATE allow CONSTRAINT SYS_C0030849;
Modified table.
SQL > ALTER TABLE USER_STATE_PARAMETER allow FK1_USR_SES_ST_PAR of CONSTRAINT;
Modified table.
-My Question is, after you disable the CONSTRAINT, I did the truncate operation, and then enable the CONSTRAINT. I do who will trust me to do not face any problem in the database of the DML OPERATION? I also found there is no CONSTRAINT to disable in my database.
>
I do
>
Nope - you would not enable foreign key constraints, if the tables had given them that reference the you truncated.
So if the constraints are enabled and valid, you will have no problem.
You can (and should) always test certain simple dml to confirm there is no problem.
Tags: Database
Similar Questions
-
Difference between the immediate and normal constraint primary key value
Hello
I tried the following to understand the difference between immediate constraint set and the primary normal stress
The above error violation even works for a normal constraints primary / uniquecreate table cust (cust_id number ,cust_name varchar2(25)); alter table cust add constraint cust_id_pk primary key(cust_id) deferrable initially deferred; SQL> insert into cust values(1,'raj'); 1 row created. SQL> insert into cust values(1,'sam'); 1 row created. SQL> commit; commit * ERROR at line 1: ORA-02091: transaction rolled back ORA-00001: unique constraint (SCOTT.CUST_ID_PK) violated SQL> set constraint cust_id_pk immediate; Constraint set. SQL> SQL> insert into cust values(1,'lata'); 1 row created. SQL> insert into cust values(1,'lata'); insert into cust values(1,'lata') * ERROR at line 1: ORA-00001: unique constraint (SCOTT.CUST_ID_PK) violated
So what is the use of the command
immediate Set constraint cust_id_pk;
Thank youSo what is the use of the command
In fact, the use of the command when you're dealing with foreign key constraints. As explained below
SQL> create table cust (cust_id number ,cust_name varchar2(25), supplier_id number); Table created. SQL> create table supp(supplier_id number); Table created. SQL> alter table supp add primary key(supplier_id); Table altered. SQL> ALTER TABLE cust ADD CONSTRAINT fk_cust_supp 2 FOREIGN KEY (supplier_id) 3 REFERENCES supp (supplier_id) 4 DEFERRABLE 5 INITIALLY deferred; Table altered.
To insert a line in the cust table without entering Ref provider table supp
SQL> insert into cust values(1,'raj',111); 1 row created.
Line by 1 created successfully (attention this validation is not yet done) because the foreign key constraint is initially deferred.
Now
SQL> set constraint fk_cust_supp immediate; set constraint fk_cust_supp immediate * ERROR at line 1: ORA-02291: integrity constraint (OWNER.FK_CUST_SUPP) violated - parent key not found
Since Ref no outs in extra table so forced provider violated.
allows to insert a row in the vendor corresponding with the vendor id in the cust table id
SQL> insert into supp values(111); 1 row created.
Now, try
SQL> set constraint fk_cust_supp immediate; Constraint set.
but now, if you try to insert a row into the table cust without this vendor id in table supp, it give error (since now forced to check from the inserted row, even will not wait for commit)
SQL> insert into cust values(3,'bob',222); insert into cust values(3,'bob',222) * ERROR at line 1: ORA-02291: integrity constraint (OWNER.FK_CUST_SUPP) violated - parent key not found
Also, in the case of primary key constraints will be checked when you perform VALIDATION, otherwise that it will allow you to insert the second row.
SQL> alter table cust add constraint cust_id_pk primary key(cust_id) 2 deferrable initially deferred; Table altered. SQL> insert into cust values(1,'raj'); 1 row created. SQL> insert into cust values(1,'sam'); 1 row created. SQL> insert into cust values(1,'bob'); 1 row created. SQL> commit; commit * ERROR at line 1: ORA-02091: transaction rolled back ORA-00001: unique constraint (OWNER.CUST_ID_PK) violated SQL>
SQL> drop table cust; Table dropped. SQL> create table cust (cust_id number ,cust_name varchar2(25)); Table created. SQL> alter table cust add constraint cust_id_pk primary key(cust_id) 2 deferrable initially deferred; Table altered. SQL> set constraint cust_id_pk immediate; Constraint set. SQL> insert into cust values(1,'raj'); 1 row created. SQL> insert into cust values(1,'sam'); insert into cust values(1,'sam') * ERROR at line 1: ORA-00001: unique constraint (OWNER.CUST_ID_PK) violated SQL>
Published by: Azhar Husain on July 27, 2011 12:01
-
create view materized without constraint primary key on the base table?
Hello
I tried to create a materized view, but I got this error:
SQL > CREATE MATERIALIZED VIEW FAST REFRESH TABLE1_MV
START BY
TO_DATE (April 25, 2009 03:00:13 ',' DD-MM-YYYY hh24:mi:ss')
NEXT
SYSDATE + 1
AS
Select * from TABLE1@remote_db
SQL > /.
CREATE MATERIALIZED VIEW FAST REFRESH TABLE1_MV
*
ERROR on line 1:
ORA-12014: table 'TABLE1' does not contain a primary key constraint.
Table1 in remote_db is not a primary key constraint. Is there anyway that I can create a view materized on a base table that is not a primary key constraint?
Thank you
LizMake sure user name used in remote_db database link has select privileges on Journal of MV. On the issue of db source:
SELECT LOG_TABLE FROM DBA_MVIEW_LOGS WHERE LOG_OWNER = 'TABLE1-owner' AND MASTER = "TABLE1";
This will give you MV table the journal name. On the issue of target side:
SELECT * from MV-LOG-NAME@remote_db;
And after your version.
SY.
-
Primary key in 11g - known problem 6894412 problem
Hello world:
We are on JDeveloper 11.1.1.4 and JHeadstart 11.1.1.2.46. This thread was initially started on the JHeadstart forum and can be seen at: problem with 11 g LOV
We are converting our application of 10g and 11g. We have an established Oracle database that does not pre-filled primary keys that are the sequence number. Our database has composite keys and the integrity of these composite keys are established by foreign key constraints to edit tables. This approach has worked very well for us for more than a decade, the logic of the database has been designed so that the database protects itself through the elimination of cascading deletes, as appropriate, and cascade deletes as the precepts of business logic. This will not change.
In the tables of the database in which the application of 10g was posted in table format, after conversion to 11g, the pop - ups LOV don't work unless you have pressed the SAVE button (or refresh the browser). The first popup LOV will work, but as soon as you select a value in the it, pop ups LOV next will not run until the SAVE or REFRESH method is done. It is only in a tabular format. If the display format is form, our main work of LOV - keys very well. In 10g, this feature has worked as long as we use a button "Add a LINE" on a table format. The add a line button caused the primary key values be returned to the application, but may not display on the screen. A refresh would then show them.
Since the original investigation in the JHeadstart forum, I realize that we are hitting 'Primary keys of the model' 6894412 problem listed in the Release Notes 11.1.1.4. We spent many, many hours creating a reusable .jar file of all of the features of this very large database such as suggested by JDeveloper best practices (http://download.oracle.com/docs/cd/B31017_01/web.1013/b25947/bcadvgen007.htm). This has worked very well for set us in 10g - details of the entity in a place, once, and then each application can reuse. Productivity at its best. Therefore, we cannot make false columns in our database in order to correct this "limitation" in 11 g. We have several complex tables of child-parent/child to put in our application that will not work unless our entities have correctly defined primary keys. I tried to implement workaround was found in the release notes, but were unable to make it work.
I created a unit test with the HRSchema by adding a table to this pattern that I can provide the SQL commands, but I do not know in Oracle taking in charge of the to send to. Could someone provide me with information on who to contact please. I, I think, took all the measures contained in the release notes for this problem and have clearly documented the changes in the .jsff page, but the problem persists. Clearly, I do something wrong, or would like more information.
Thanks in advance
Mary
UHello
There is no "" one person in support to send it directly to. Apply you for Services using http://metalink.oracle.com/ report the problem and download your test scenario. Support then concludes the expert to analyze
Frank
-
modify a primary key constraint
Hello
I start with oracle, and I have two doubts which cannot handle after a search on the internet.
1. it is possible to do an ALTER TABLE for a DEFAULT CONSTRAINT?. Maybe you think that the question should be in a different way like this: oracle database takes the default condition as a constraint?. As far as I know, not done that.
2. it is possible, with an ALTER TABLE to CHANGE a CONSTRAINT of a PRIMARY KEY, to add another field more?
I searched the internet, but I have not found a clear answer. I use oracle 10g express edition.
Thank you very much.
P.D.:sorry for my English, it is not very good.#2-you can not 'add a column to the primary key of a table constraint' with a single ALTER, but you can delete and re-create the constraint primary key (including the additional column).
13:25:26> create table t1 (a number primary key, b number, c number ); Table created. Elapsed: 00:00:00.09 13:25:46> alter table t1 drop primary key; Table altered. Elapsed: 00:00:00.06 13:25:47> alter table t1 add primary key (a,b); Table altered. Elapsed: 00:00:00.09
But you will not be able to drop the primary key of a table index.
13:25:47> create table t2 (a number primary key, b number, c number ) organization index; Table created. Elapsed: 00:00:00.03 13:25:59> alter table t2 drop primary key; alter table t2 drop primary key * ERROR at line 1: ORA-25188: cannot drop/disable/defer the primary key constraint for index-organized tables or sorted hash cluster Elapsed: 00:00:00.00 13:25:59>
#1-I'm not sure I understand your question, but you can change a table column to have a default value. This isn't a "constraint", but a default value. It has an effect when you perform an insert which does not include this column.
13:31:23> alter table t1 modify (c default 3.14); Table altered. Elapsed: 00:00:00.04 13:31:24> insert into t1 (a,b,c) values (1,2,3); 1 row created. Elapsed: 00:00:00.01 13:31:24> insert into t1 (a,b,c) values (4,5,NULL); 1 row created. Elapsed: 00:00:00.00 13:31:24> insert into t1 (a,b) values(6,7); 1 row created. Elapsed: 00:00:00.01 13:31:24> select * from t1; A B C ---------- ---------- ---------- 1 2 3 4 5 6 7 3.14 3 rows selected. Elapsed: 00:00:00.18
-
updated primary key of the problem 10 gr 2 (10.1.2.0.1)
Primary key can be updated... How to protectiloveoracle wrote:
Primary key can be updated...Yes - longer updating does not violate constraint primary key
How to protect
Trigger.
-
A composite primary key needs of the Unique ID column or not?
Hello dear,
I have a table that's the primary key is a key that is composed of two columns and there are like 5 columns of information. You think I'm going to use two columns as the primary key of this table or create a unique ID column.
Example:
Employees table:
Services of table:
The table of the problem is the Department managers:
Now, I'll add employee id and service id in this table and Manager info etc... (info does not exist in the employee table), should I use as primary or create the id column in this table?
Thank you very much.You must use the new ID as primary (alter table add constraint primary key,...) you cannot use foreign key as primary :)
-
DROP TABLE TWO.
DROP TABLE ONE;
CREATE TABLE 'A
(
ACTIVATE THE 'ID' NUMBER NOT NULL,
ACTIVATE THE "SERIAL" VARCHAR2 (10 BYTE) NOT NULL,
ACTIVATE THE "FIRST NAME" VARCHAR2 (30 BYTE) NOT NULL,
ENABLE 'PK_ONE' CONSTRAINT PRIMARY KEY ('ID', "SERIAL")
)
TABLESPACE 'USERS ';
CREATE TABLE "TWO"
(
ACTIVATE THE 'ID' NUMBER NOT NULL,
ACTIVATE THE "SERIAL" VARCHAR2 (5 BYTE) NOT NULL,
ACTIVATE THE "DEGREE_CODE" VARCHAR2 (10 BYTE) NOT NULL,
'TEST_NAME' VARCHAR2 (20 BYTE),
ACTIVATE THE KEY PRIMARY CONSTRAINT 'PK_TWO' ('ID', 'SERIAL'),
"FK_TWO' FOREIGN KEY ('ID', 'DEGREE_CODE') CONSTRAINT REFERS TO 'ONE' ('ID', 'SERIAL') MAYBE DEFERRED ENABLE
)
TABLESPACE 'USERS ';
If we use the above sql scripts to create the tables and create the ADF BC using the above 2 tables, all 4 columns in table 2 are reported as the primary key.
User, tell us your version of Jdev, please!
You should file an SR with support.oracle.com for this.
As a work around you can change the area of occurrence, and remove the check mark key pirmary on the unwanted columns. After that, it should work.
Timo
-
If it does not create an orphan can not drop us a primary key?
My book says no. Steve O'Hearn page text 1z0-047 432.
For example, consider this code:
CREATE TABLE CRUISE_ORDERS
(NUMBER OF CRUISE_ORDER_ID,
ORDER_DATE DATE,
PK_CO (CRUISE_ORDER_ID, ORDER_DATE) PRIMARY KEY CONSTRAINT);
CREATE TABLE ORDER_RETURNS
(NUMBER OF ORDER_RETURN_ID,
NUMBER OF CRUISE_ORDER_ID
DATE OF CRUISE_ORDER_DATE,
CONSTRAINT PK_OR PRIMARY KEY (ORDER_RETURN_ID).
FOREIGN KEY CONSTRAINT FK_OR_CO
(CRUISE_ORDER_ID, CRUISE_ORDER_DATE)
REFERENCES CRUISE_ORDERS (CRUISE_ORDER_ID, ORDER_DATE));
These SQL statements will create two tables with a FOREIGN KEY relationship
linking them together - see Figure 11 - 1 for the model of data representing the
relationship.
In the CRUISE_ORDERS table that we just created, we cannot let down the CRUISE_
ORDER_ID column or the ORDER_DATE column, for two different reasons:
They are part of the PRIMARY KEY constraint and forced to columns
cannot be deleted unless the constraint first fell;
They are part of the key referred to in the FOREIGN KEY of another table.
They cannot be deleted as long as a FOREIGN KEY constraint refers to them.
Similarly, we cannot remove the column the table ORDER_RETURNS that
is subject to the constraint PRIMARY KEY (ORDER_RETURN_ID), or the...
Easily, you should be able to remove the column order_return_id. I did it myself. Only, I caught this post back to the chapter for a review and it made no sense to me. Perhaps because it refers to PL/SQL or an older version? (the book is 5 years old).
In any case I do not see why a primary key without dependent columns could not be deleted.
Like I said I tested it, and it can be moved.
This isn't what the text says. It is said that if PK in question is mentioned by a FK, you can not remove the PK. If you take the part of the sentence on its own "BOLD", it is obviously fake.
-
Hello everyone.
Is there a way to create the primary key by order of decreasing its index?
I have a sql for MSSQL that looks like:
ALTER TABLE table_name ADD CONSTRAINT pk_name
KEY elementary SCHOOL (Column1 Column2 Column3 DESC, DESC, DESC)
How can I make in Oracle?
I tried this:
ALTER TABLE table_name
ADD CONSTRAINT PRIMARY KEY pk_name
*(*
Column1 DESC
*, Column2 DESC *.
*, Column3 DESC *.
*)*
ENABLE;
but I got this error:
Error report:
SQL error: ORA-00907: lack the right parenthesis
* 00907. 00000 - "lack the right parenthesis."
* Question: *.
* Action. *A reverse key index is distinguished by an index of desc.
I don't think that you can create a descending index to support a primary key because in Oracle a descending index is implemented as an index based on a function by using SYS_OP_DESCEND.
But you can create a unique index, for example
CREATE UNIQUE INDEX
ON ( The question is always why.
You can use an ascending index to make a descending sort. Maybe cannot MSSQL?
-
disable the primary key with waterfall
Hello everyone,
I just want to know
1. What is the effect after we diasble cascade a constraint primary key with the option?
2 should rebuild us the index after you have enabled the constraint? How?
Please explain with an example...
Thanx2 should rebuild us the index after you have enabled the constraint? How?
The index will be re-created for you automatically when you enable constraint even once:
SQL> create table t (i integer constraint t_pk primary key) / Table created. SQL> select index_name, uniqueness from user_indexes where table_name = 'T' / INDEX_NAME UNIQUENES ------------------------------ --------- T_PK UNIQUE 1 row selected. SQL> alter table t disable primary key cascade / Table altered. SQL> select index_name, uniqueness from user_indexes where table_name = 'T' / no rows selected. SQL> alter table t enable primary key / Table altered. SQL> select index_name, uniqueness from user_indexes where table_name = 'T' / INDEX_NAME UNIQUENES ------------------------------ --------- T_PK UNIQUE 1 row selected. SQL> drop table t / Table dropped.
-
Create primary key also Select
In Oracle, how we specify a primary key in a creation like the select statement? I ran a simple statement, but received the error ORA-00933. What I have to do two steps with created first table and alter the table to add the key?
Thank you
CREATE TABLE Test as
SELECT
*
SOURCE one
WHERE a.sys = 100
PK1 CONSTRAINT PRIMARY KEY (account ID)SQL> create table t (a primary key) as select 1 from dual / Table created.
-
Another syntax for creating primary key
Hello
I have a question about the right way to create primary keys.
Earlier, we were on Oracle 9i and we have upgraded to Oracle 10 g. The question is when creating primary key is allowed to create the unique index and then to create the primary key constraint? or directly create the first key is better? or are there ways to both the same?
for example:
one way:
SQL & gt; CONN u2/u2@db1
Connected.
SQL & gt; create table a (a1, b1 varchar2 number (2), the date c1);
Table created.
SQL & gt; create an index on a (a1) tablespace unique pk_a t1;
The index is created.
SQL & gt; ALTER table a Add (constraint primary key (a1) using index pk_a);
Modified table.
Another way:
SQL & gt; CONN u1/u1@db1
Connected.
SQL & gt; create table a (a1, b1 varchar2 number (2), the date c1)
2.
Table created.
SQL & gt;
SQL & gt; ALTER table a Add (constraint primary key (a1) using index tablespace t1 pk_a)
2.
Modified table.
Which of the two approach is better? or are they the same?
Thank you
Cedric
Oracle will attempt to create the index to apply the constraint. Of course, it is certainly possible that the creation of the index will fail, but you would be just to move the point of failure of the CREATE INDEX statement to the ALTER TABLE statement, assuming that everything else is equal (that is, you create the index in the same tablespace, quotas and tablespace sizes are the same, permissions are not changed, etc.)
It may be preferable in some contexts to create a non-unique index before the creation of the constraint and instruct Oracle to use the non-unique index to apply the constraint. If you decide in the future to make the primary key constraint can be delayed, for example, have a non-unique index allows you to make this change without having to (implicitly), drop and re-create the index. A separate CREATE INDEX statement also influences when you go to remove a constraint / index. If the index was created before the constraint, you can remove the constraint without affecting the index. If the index was created after the constraint, deleting the constraint implicitly removes the index. Normally, particularly with OLTP applications, this doesn't buy you much. Sometimes, however, there are ETL process benefiting from such things.
Justin
-
Primary key cause problem in the meantime Partition Exchange
DB: 11.2.0.2
OPERATING SYSTEM: AIX 6.1
I get the problem when exchanging data with range partitioned table. I have a partitioned table of interval and a regular intermediate table with data to be uploaded.
Here are the steps that I did.
Now, if I turn off and drop the primary key constraint, it works without any problem.SQL> CREATE TABLE DEMO_INTERVAL_DATA_LOAD ( ROLL_NUM NUMBER(10), CLASS_ID NUMBER(2), ADMISSION_DATE DATE, TOTAL_FEE NUMBER(4), COURSE_ID NUMBER(4)) PARTITION BY RANGE (ADMISSION_DATE) INTERVAL (NUMTOYMINTERVAL(3,'MONTH')) ( PARTITION QUAT_1_2012 VALUES LESS THAN (TO_DATE('01-APR-2012','DD-MON-YYYY')), PARTITION QUAT_2_2012 VALUES LESS THAN (TO_DATE('01-JUL-2012','DD-MON-YYYY')), PARTITION QUAT_3_2012 VALUES LESS THAN (TO_DATE('01-OCT-2012','DD-MON-YYYY')), PARTITION QUAT_4_2012 VALUES LESS THAN (TO_DATE('01-JAN-2013','DD-MON-YYYY'))); Table created. SQL> ALTER TABLE DEMO_INTERVAL_DATA_LOAD ADD CONSTRAINT IDX_DEMO_ROLL PRIMARY KEY (ROLL_NUM); Table altered. SQL> SELECT TABLE_OWNER, TABLE_NAME, COMPOSITE, PARTITION_NAME, PARTITION_POSITION, TABLESPACE_NAME, LAST_ANALYZED FROM DBA_TAB_PARTITIONS WHERE TABLE_OWNER='SCOTT' AND TABLE_NAME='DEMO_INTERVAL_DATA_LOAD' ORDER BY PARTITION_POSITION; TABLE_OWNER TABLE_NAME COM PARTITION_NAME PARTITION_POSITION TABLESPACE_NAME LAST_ANAL ------------------------------ ------------------------------ --- ------------------------------ ------------------ ------------------------------ --------- SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_1_2012 1 USERS SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_2_2012 2 USERS SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_3_2012 3 USERS SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_4_2012 4 USERS SQL> INSERT INTO DEMO_INTERVAL_DATA_LOAD VALUES (10,1,'12-MAR-2012',1000,90); 1 row created. SQL> INSERT INTO DEMO_INTERVAL_DATA_LOAD VALUES (11,5,'01-JUN-2012',5000,80); 1 row created. SQL> INSERT INTO DEMO_INTERVAL_DATA_LOAD VALUES (12,9,'12-SEP-2012',4000,20); 1 row created. SQL> INSERT INTO DEMO_INTERVAL_DATA_LOAD VALUES (13,7,'29-DEC-2012',7000,10); 1 row created. SQL> INSERT INTO DEMO_INTERVAL_DATA_LOAD VALUES (14,8,'21-JAN-2013',2000,50); ---- This row will create a new interval partition in table. 1 row created. SQL> commit; SQL> SELECT TABLE_OWNER, TABLE_NAME, COMPOSITE, PARTITION_NAME, PARTITION_POSITION, TABLESPACE_NAME, LAST_ANALYZED FROM DBA_TAB_PARTITIONS WHERE TABLE_OWNER='SCOTT' AND TABLE_NAME='DEMO_INTERVAL_DATA_LOAD' ORDER BY PARTITION_POSITION; TABLE_OWNER TABLE_NAME COM PARTITION_NAME PARTITION_POSITION TABLESPACE_NAME LAST_ANAL ------------------------------ ------------------------------ --- ------------------------------ ------------------ ------------------------------ --------- SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_1_2012 1 USERS SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_2_2012 2 USERS SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_3_2012 3 USERS SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_4_2012 4 USERS SCOTT DEMO_INTERVAL_DATA_LOAD NO SYS_P98 5 USERS SYS_P98 partition is added to table automatically. SQL> CREATE TABLE DEMO_INTERVAL_DATA_LOAD_Y ( ROLL_NUM NUMBER(10), CLASS_ID NUMBER(2), ADMISSION_DATE DATE, TOTAL_FEE NUMBER(4), COURSE_ID NUMBER(4)); Table created. SQL> INSERT INTO DEMO_INTERVAL_DATA_LOAD_Y VALUES (30,3,'21-MAY-2013',2000,12); 1 row created. SQL> commit; Commit complete. Since, i need a partition in DEMO_INTERVAL_DATA_LOAD table, which can be used in partition exchange, so i create a new partition as below: SQL> LOCK TABLE DEMO_INTERVAL_DATA_LOAD PARTITION FOR (TO_DATE('01-APR-2013','DD-MON-YYYY')) IN SHARE MODE; Table(s) Locked. SQL> SELECT TABLE_OWNER, TABLE_NAME, COMPOSITE, PARTITION_NAME, PARTITION_POSITION, TABLESPACE_NAME, LAST_ANALYZED FROM DBA_TAB_PARTITIONS WHERE TABLE_OWNER='SCOTT' AND TABLE_NAME='DEMO_INTERVAL_DATA_LOAD' ORDER BY PARTITION_POSITION; TABLE_OWNER TABLE_NAME COM PARTITION_NAME PARTITION_POSITION TABLESPACE_NAME LAST_ANAL ------------------------------ ------------------------------ --- ------------------------------ ------------------ ------------------------------ --------- SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_1_2012 1 USERS SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_2_2012 2 USERS SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_3_2012 3 USERS SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_4_2012 4 USERS SCOTT DEMO_INTERVAL_DATA_LOAD NO SYS_P98 5 USERS SCOTT DEMO_INTERVAL_DATA_LOAD NO SYS_P102 6 USERS SQL> ALTER TABLE DEMO_INTERVAL_DATA_LOAD EXCHANGE PARTITION SYS_P102 WITH TABLE DEMO_INTERVAL_DATA_LOAD_Y INCLUDING INDEXES WITH VALIDATION; ALTER TABLE DEMO_INTERVAL_DATA_LOAD * ERROR at line 1: ORA-14097: column type or size mismatch in ALTER TABLE EXCHANGE PARTITION
Please suggest.SQL> alter table DEMO_INTERVAL_DATA_LOAD disable constraint IDX_DEMO_ROLL; Table altered. SQL> alter table DEMO_INTERVAL_DATA_LOAD drop constraint IDX_DEMO_ROLL; Table altered. SQL> ALTER TABLE DEMO_INTERVAL_DATA_LOAD EXCHANGE PARTITION SYS_P102 WITH TABLE DEMO_INTERVAL_DATA_LOAD_Y INCLUDING INDEXES WITH VALIDATION; Table altered. SQL> select * from DEMO_INTERVAL_DATA_LOAD partition (SYS_P102); ROLL_NUM CLASS_ID ADMISSION TOTAL_FEE COURSE_ID ---------- ---------- --------- ---------- ---------- 30 3 21-MAY-13 2000 12 SQL> select * from DEMO_INTERVAL_DATA_LOAD_Y; no rows selected
First of all, thanks for posting the code that allows us to reproduce your test. It is essential for such problems.
Because the primary key is global you will not be able to use
INCLUDING INDEXES WITH VALIDATION;
And you need to add the primary key to the temporary table
ALTER TABLE DEMO_INTERVAL_DATA_LOAD_Y ADD CONSTRAINT IDX_DEMO_ROLL_Y PRIMARY KEY (ROLL_NUM);
The Exchange will work. You must rebuild the primary key after the Exchange.
-
Problem with the primary key and indexes
Hi all
I'm looking a mess on one of our main tables.
One of the developers here added an index on 3 columns in the table, thinking that it would speed up (not noticing that it had not a PK).
Subsequently another developer has noticed there do not have a primary on key. So they added a touch of primry on the single column.
The problem is that now the index created on 3 columns is bein used as the primary key index. As when the primary key is created a new index was not created.
Is there anyway to get rid of this index/change it correct?
This table is related to many many other tables, so when we tried to remove the index we could not due to the primary key and foreign key violations with other tables.
Thanks in advanceOracle, as you found, is quite capable to use a column enformce multi index a single column primary key, as long as the pk column is the leader in the index. This should not cause performance issues for a search of PK and if the three indexed columns are often selected only may benefit from these types of queries.
The only way to change that now, would be to drop all CF, drop and add the PK constraint and then add all the FK constraints. A long time and potentially dangerous (if you miss to add back of the FKs) endeavour. Certainly not worth the risk in my opinion.
John
Maybe you are looking for
-
reset only your ID for me apple is hidden? !!!
Hello I forgot the security question apple id? Why the Option reset your ID question apple is hidden for me? Please, help me
-
Question about blu ray disc player update for Satellite C850-B124
My Toshiba Tempro is telling me that I have an update for the blu ray disc drive, so I opened it and it said s a package of 32-bit but my Windows 7 is 64-bit, so I'm confused. Should I download and install? Or I'll just ignore it? I m using Toshiba S
-
Create a new collection for 2016
Hi, I have to create a new collection for 2016 or OSX photos will do it automatically?
-
HP Photosmart 5520: Duplex HP5520
Please can someone advise on Duplex (duplex) printing a PDF file by doing a HP5520 connected to an iMAC computer. I don't see any option for it in the settings. Thank you
-
HP Officejet Pro X576dw: HP Officejet Pro X576dw is not compatible with Windows 10
I am looking to buy this printer and I was wondering if it will work. HP Officejet Pro X576dw is compatible with Windows 10?