Add unique constraint only if it not exists
hello racle community,
I would like to create a unique constraint (at least over two columns) on several tables via a script. Is there any way to fire the ALTER TABLE statement only when a constraint over the same columns does not exists already ? Or do I have to query the USER_CONSTRAINTS table first ?
Ikrischer
Yes, something like this:
set serveroutput on
declare
UNIQUE_CONS_EXISTS exception;
pragma exception_init(UNIQUE_CONS_EXISTS, -2261);
begin
for r in (select table_name
,rownum rn
from all_tables where ....) loop
begin
execute immediate 'alter table ' || r.Table_Name || ' add constraint i_' || r.rn || ' unique (col1,col2)';
when UNIQUE_CONS_EXISTS then
dbms_output.put_line(sqlerrm);
end;
end loop;
dbms_output.put_line('Done');
end;
/The only thing to bear in mind is that your constraint names will simply be numbered increments and will have no meaning.
Similar Messages
-
The constraints ddl clause does not exists in indexfile using imp tools
SQL> -- Create table
SQL> create table TB_EXP_TEST
2 (
3 OWNER VARCHAR2(30) not null,
4 OBJECT_NAME VARCHAR2(128) not null,
5 SUBOBJECT_NAME VARCHAR2(30),
6 OBJECT_ID NUMBER not null,
7 DATA_OBJECT_ID NUMBER,
8 OBJECT_TYPE VARCHAR2(19),
9 CREATED DATE,
10 LAST_DDL_TIME DATE,
11 TIMESTAMP VARCHAR2(19),
12 STATUS VARCHAR2(7),
13 TEMPORARY VARCHAR2(1),
14 GENERATED VARCHAR2(1),
15 SECONDARY VARCHAR2(1),
16 NAMESPACE NUMBER,
17 EDITION_NAME VARCHAR2(30)
18 )
19 tablespace USERS
20 pctfree 10
21 initrans 1
22 maxtrans 255
23 storage
24 (
25 initial 9M
26 next 1M
27 minextents 1
28 maxextents unlimited
29 );
Table created.
SQL> -- Create/Recreate primary, unique and foreign key constraints
SQL> alter table TB_EXP_TEST
2 add constraint EXP_TEST_PK primary key (OBJECT_ID)
3 using index
4 tablespace USERS
5 pctfree 10
6 initrans 2
7 maxtrans 255
8 storage
9 (
10 initial 2M
11 next 1M
12 minextents 1
13 maxextents unlimited
14 );
Table altered.
SQL> -- Create/Recreate indexes
SQL> create index IDX_TB_EXP_TEST_N1 on TB_EXP_TEST (OBJECT_NAME)
2 tablespace USERS
3 pctfree 10
4 initrans 2
5 maxtrans 255
6 storage
7 (
8 initial 4M
9 next 1M
10 minextents 1
11 maxextents unlimited
12 );
Index created.
SQL> Insert Into TB_EXP_TEST
2 Select * From Dba_Objects Where object_id Is Not Null;
76143 rows created.
SQL>exit;
exp hxl/hxl@orcl file=c:\exptest.dmp tables=(tb_exp_test);
SQL>drop table tb_exp_test;
imp hxl/hxl@orcl file=c:\exptest.dmp tables=(tb_exp_test) constraints=Y indexes=Y indexfile=C:\index.txtThe index.txt contents is flowing,but the add constraint EXP_TEST_PK primary key not exists ,and it is remed,Why?
REM CREATE TABLE "HXL"."TB_EXP_TEST" ("OWNER" VARCHAR2(30) NOT NULL
REM ENABLE, "OBJECT_NAME" VARCHAR2(128) NOT NULL ENABLE, "SUBOBJECT_NAME"
REM VARCHAR2(30), "OBJECT_ID" NUMBER, "DATA_OBJECT_ID" NUMBER,
REM "OBJECT_TYPE" VARCHAR2(19), "CREATED" DATE, "LAST_DDL_TIME" DATE,
REM "TIMESTAMP" VARCHAR2(19), "STATUS" VARCHAR2(7), "TEMPORARY"
REM VARCHAR2(1), "GENERATED" VARCHAR2(1), "SECONDARY" VARCHAR2(1),
REM "NAMESPACE" NUMBER, "EDITION_NAME" VARCHAR2(30)) PCTFREE 10 PCTUSED
REM 40 INITRANS 1 MAXTRANS 255 STORAGE(INITIAL 9437184 NEXT 1048576
REM MINEXTENTS 1 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
REM TABLESPACE "USERS" LOGGING NOCOMPRESS ;
REM ... 76141 rows
CONNECT HXL;
CREATE INDEX "HXL"."IDX_TB_EXP_TEST_N1" ON "TB_EXP_TEST" ("OBJECT_NAME" )
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 4194304 NEXT 1048576
MINEXTENTS 1 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE
"USERS" LOGGING ;
CREATE UNIQUE INDEX "HXL"."EXP_TEST_PK" ON "TB_EXP_TEST" ("OBJECT_ID" )
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 2097152 NEXT 1048576
MINEXTENTS 1 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE
"USERS" LOGGING ;
REM ALTER TABLE "HXL"."TB_EXP_TEST" ADD CONSTRAINT "*EXP_TEST_PK*" PRIMARY
REM KEY ("OBJECT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
REM STORAGE(INITIAL 2097152 NEXT 1048576 MINEXTENTS 1 FREELISTS 1
REM FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "USERS" LOGGING
REM ENABLE ;Pavan Kumar wrote:
Hi,
Are you sure on that - but we can able view from the text which you floated across here (or) else my understanding is wrong with respect your question across.
- Pavan Kumar NI sure the code is not any problem. -
Add HW Inventory class that does not exist in a default inventoried class
Hello all,
I am trying to find a way to create a new class to supersede the win32_logicaldisk class. We are looking to add the VolumeDirty flag since it does not exist in the current SMS_logicaldisk class. However I cant seem to find a good way to do this. Has anyone
done something like this before? Adding new classes doesn't seem to be difficult, but since this is a default WMI class that is being inventoried, I don't want to make any modifications to it as I know I will regret it down the road. I was thinking maybe creating
a configuration item and inventorying it that way? Thoughts? Or is this even possible? Thanks in advance!
ScottI do similar things--create a new I-Made-It-Up class to pull in something that the default doesn't. I understand and agree with not modifying default classes--it perhaps would never be a problem--but if (perhaps maybe) some future upgrade or cumulative
update failed to install because you modified a default class, it could be a sad sad day. :)
If you want me to just write the mof edit for you, let me know. Otherwise for a sample of how to do that; look at the mof edits for 'making up my own' SQL inventory:
http://mnscug.org/blogs/sherry-kissinger/328-installed-sql05-sql08-sql12-sql14-version-information-via-configmgr-hardware-inventory
Essentially, you make up a configuration.mof edit; making a 'copy of' what you really want out of win32_logicaldisk, but you dump it into a cm_scott_x_awesomeness (or whatever you want to call it), and you put that at the bottom of configuration.mof
on your server.
Then your to-be-imported.mof into default client, hardware inventory, classes... import (if you're old skool, the sms_def.mof piece of it) will be a .mof file to inventory cm_scott_x_awesomeness
Just be careful to name what you really want to see in v_gs_NameThatView inside the quotes SMS_Group_Name and SMS_Class_ID. You'll be living with that table and view name forever, so maybe, perhaps, calling it Scott_X_Awesomeness just might not be
the best name ever (although it sounds great right now, at review time w/the boss maybe not so much).
Standardize. Simplify. Automate. -
Add Unique Constraint - Unable to extend temp segment
I'm getting the error "ORA-01652: unable to extend temp segment by 1024 in tablespace ...". I'm a developer, and our DBA is on vacation. I'm trying to understand what's happening, so I monitor V$SORT_SEGMENT while the constraint is being created. Here is what that view looks like immediately before and after the exception is thrown:
10:43:07 < ... > select * from v$sort_segment;
TABLESPACE_NAME SEGMENT_FILE SEGMENT_BLOCK EXTENT_SIZE CURRENT_USERS TOTAL_EXTENTS TOTAL_BLOCKS USED_EXTENTS USED_BLOCKS FREE_EXTENTS FREE_BLOCKS ADDED_EXTENTS EXTENT_HITS FREED_EXTENTS
FREE_REQUESTS MAX_SIZE MAX_BLOCKS MAX_USED_SIZE MAX_USED_BLOCKS MAX_SORT_SIZE MAX_SORT_BLOCKS RELATIVE_FNO
TEMP 0 0 128 1 460 58880 460 58880 0 0 460 505 2809
1 2809 359552 460 58880 460 58880 0
Elapsed: 00:00:00.04
10:43:13 < ... > select * from v$sort_segment;
TABLESPACE_NAME SEGMENT_FILE SEGMENT_BLOCK EXTENT_SIZE CURRENT_USERS TOTAL_EXTENTS TOTAL_BLOCKS USED_EXTENTS USED_BLOCKS FREE_EXTENTS FREE_BLOCKS ADDED_EXTENTS EXTENT_HITS FREED_EXTENTS
FREE_REQUESTS MAX_SIZE MAX_BLOCKS MAX_USED_SIZE MAX_USED_BLOCKS MAX_SORT_SIZE MAX_SORT_BLOCKS RELATIVE_FNO
TEMP 0 0 128 0 460 58880 0 0 460 58880 460 505 2809
1 2809 359552 460 58880 460 58880 0
Elapsed: 00:00:00.02My DBA had previously instructed me to issue this command to try to avoid this error:
alter database tempfile '...' resize 12g;I do that, but I still only show 460 free segments. Can someone point me to some documentation on how to make the Free Extents be larger than 460?
Here's my client info:
SQL*Plus: Release 11.2.0.3.0 Production on Tue Nov 6 10:40:39 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.Here's my server info:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing optionsGiven that you appear to be able to add/increase temp files, you are also likely to be able to see the dba_* views. As a first shot, try:
select sum(bytes) from dba_free_space
where tablespace_name = <name from the error message>If there appears to be sufficient space (no idea what that would be since I do not know how big your objects are) then try something like:
select file_id, block_id, bytes from dba_free_space
where tablespace_name = <name from the error message>
order by bytes descIf you have large amounts of contiginous free space (i.e. the first few rows have a large value for the bytes column) then ther may be something else going on.
If both queries show relativel small values for the amount of free space, you will need to add another datafile to the tablespace, or increase the size of one of the existing datafile.
To see the datafiles in the tablespace use:
select file_name, bytes from dba_data_files
where tablespace_name = <name from the error message>You can increase the size of a datafile using something similar to the alter database command you have for the tempfiles like:
alter database datafile <a quoted full name from dba_data_files> resize some bigger numberJust make sure that the file system has enough free space for the new size.
John -
Need help: unique constraint
Hey please tell How to add unique constraint on two columns on a table say
Name and id
Name should be case independent unique
something like
alter table xyz. add unique constraint on (upper(name),id )
ThnxSQL> create table xyz
2 ( name varchar2(10)
3 , id number(4)
4 )
5 /
Tabel is aangemaakt.
SQL> alter table xyz. add unique constraint on (upper(name),id )
2 /
alter table xyz. add unique constraint on (upper(name),id )
FOUT in regel 1:
.ORA-00903: invalid table name
SQL> create unique index i1 on xyz (upper(name),id)
2 /
Index is aangemaakt.
SQL> insert into xyz values ('abc',1)
2 /
1 rij is aangemaakt.
SQL> insert into xyz values ('def',1)
2 /
1 rij is aangemaakt.
SQL> insert into xyz values ('DEF',1)
2 /
insert into xyz values ('DEF',1)
FOUT in regel 1:
.ORA-00001: unique constraint (RWK.I1) violatedRegards,
Rob. -
Table does not exist when creating FK Constraint across schemas
Hi all,
This will probably boil down to a permissions issue since I'm sketchy on the various levels....
I'm testing a conversion to Oracle from our legacy system. There are 4 schemas which I've created and each of those schema users have been granted DBA roles.
After creating a number of tables I wrote the SQL to create the FK Constraints. Most of them went in, but the ones crossing schemas don't. Logged in as SYS, I can do a select from each table, I can even JOIN the two in the SELECT. However when I try creating the constraint it give me a: ORA-00942: table or view does not exist
ALTER TABLE USERA.TABLEA ADD FOREIGN KEY (COLA) REFERENCES USERB.TABLEB (COLA) ON DELETE CASCADE
Again, I have scads of commands that went in correctly so this must be a permissions type thing. I'm the only one logged into the database since it's my own test system. This is 10g BTW.
If you have any suggestions as what to look into, please explain how to actually perform the checks since I'm still learning how to get around.
Thanks very much!To bulk grant, you can use dynamic SQL; somthing like this:
<BR><BR>
SQL> declare
2 l_grantor VARCHAR2(30) := 'USERA';
3 l_grantee VARCHAR2(30) := 'USERB';
4 begin
5 for table_rec in (select owner,table_name from all_tables where OWNER=l_grantor) loop
6 execute immediate 'GRANT REFERENCES ON '||table_rec.OWNER||'.'||table_rec.TABLE_NAME||' TO '||l_grantee;
7 end loop;
8 end;
9 / -
Adding a UNIQUE Constraint to an existing table
Hi,
I got this issue because of the existing data. My issue is in my table I want to add a unique constraint to two columns but i cannot add this becuase of the existing repeating data. And I cannot do a data repair to fix the repeating data since the customer is reling on this data so we can not get the decision to repair the data.
As a solution I try this method, by adding a function to check the repeating data before inserting the data to the table. It's working fine to a user but when it come to multiple users it's not working because users can log to the database and can do their transactions simultaneously.
My question is; is there a way in oracle to add a constraint to the data that can add in future not to the old existing data?
Thanks,
Darex.user9359353 wrote:
Hi,
As a solution I try this method, by adding a function to check the repeating data before inserting the data to the table. It's working fine to a user but when it come to multiple users it's not working because users can log to the database and can do their transactions simultaneously.
show us what is "not working". if you are calling this function from a trigger the correct way, the first person to commit will have their data inserted and the next person will not be able to insert.
edit: you may want to have a read through this thread: where I was encountering a problem with multi-row validation using triggers:
Row level validation dependant on other rows?
note this post:
Rob van Wijk wrote:
Hi WhiteHat,
Here are two blogposts of mine about this subject that you might find useful.
One with some guidelines about implementing entity rules: http://rwijk.blogspot.com/2008/08/implementing-entity->rules.html
And one with an example how to implement (among others) an overlap check in the context of another option for your >question, the product RuleGen: http://rwijk.blogspot.com/2008/05/rulegen-test.html
Hope this helps.
Regards,
Rob.Edited by: WhiteHat on Jun 8, 2011 3:51 PM -
HOWTO: Add a UNIQUE constraint to a populated column
Here is the way to add a unique constraint to a populated column, ensuring that the existing values are unique as well.
ALTER TABLE t1
ADD CONSTRAINT t1_uk UNIQUE (col1,col2)
EXCEPTIONS INTO my_exceptions
/If the alter table statement fails this will populate the MY_EXCEPTIONS table with the rows that contain duplicate values for (col1,col2). These are identified by ROWID. We can then chose to:
[list]
[*]delete rows with a bad key;
[*]amend the values of the key columns;
[*]re-apply the constraint with the NOVALIDATE option.
[list]
We should be wary of choosing the NOVALIDATE option. There's usually a good reason why the unique constraint is required and we should not circumvent it. Apart from anything else, Oracle allows us to build foreign keys referencing NOVALIDATE unique keys. This could result in child rows that have two parents, which is normal in biology, but very wrong in a database.
NOVALIDATE is useful in datawarehouses and suchlike, because little updating occurs and the data integrity issues are of less imporatance. I don't think it ought to be used in OLTP situations. The code example at the end of this posting illustrates why we should exercise caution with NOVALIDATE.
Once we have handled the duplicate values we can re-run the alter table statement and apply the constraint.
If you don't already have an EXCEPTIONS table (it can be called anything, it's the structure that counts) you may need to run (or get a DBA to run) a script called UTLEXCPT.SQL, which will be in the $ORACLE_HOME/rdbms/admin directory.
Cheers, APC
SQL> SELECT col1, col2, col3 FROM t1;
COL1 COL2 COL3
1 1 0
2 1 0
2 1 0
SQL> SELECT col1, col2, cola FROM t2;
COL1 COL2 COLA
1 1 I'm child #1
1 1 I'm child #2
2 1 I'm child #3
SQL> ALTER TABLE t1
2 ADD CONSTRAINT t1_uk UNIQUE (col1, col2);
ALTER TABLE t1 ADD CONSTRAINT t1_uk UNIQUE (col1, col2)
ERROR at line 1:
ORA-02299: cannot validate (TST2.T1_UK) - duplicate keys found We can't add a unique key, so we decide to use the NOVALIDATE clause.
SQL> CREATE INDEX t1_i ON t1(col1, col2);
Index created.
SQL> ALTER TABLE t1
2 ADD CONSTRAINT t1_uk UNIQUE (col1, col2) ENABLE NOVALIDATE;
Table altered.
SQL> INSERT INTO t1 VALUES (2, 1, 1);
insert into t1 values (2, 1, 1)
ERROR at line 1:
ORA-00001: unique constraint (TST2.T1_UK) violated Well, we can't add any more duplicate keys, so that's alright isn't it? Nope. We can add a foreign key to table T2 referencing T1 but we don't know which row in T1 is the parent of the rows in T2.
SQL> ALTER TABLE t2
2 ADD CONSTRAINT t2_t1_fk foreign key (col1, col2)
3 REFERENCES t1(col1, col2)
Table altered.
SQL> SELECT rowid FROM t1 WHERE col1 = 2;
ROWID
AAAVnMAANAAAB96AAB
AAAVnMAANAAAB96AAC
SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAB';
1 row deleted.
SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAC';
DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAC'
ERROR at line 1:
ORA-02292: integrity CONSTRAINT (TST2.T2_T1_FK) violated - child record found
SQL> ROLL
Rollback complete.
SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAC';
1 row deleted.
SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAB';
DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAB'
ERROR at line 1:
ORA-02292: integrity CONSTRAINT (TST2.T2_T1_FK) violated - child record found
SQL> ROLL
Rollback complete.
Why this matters: queries joining child and parent tables return more rows than we'd expect normally.
SQL> SELECT t2.cola
2 FROM t2
3 WHERE t2.col1 = 2
4 and t2.col2 = 1;
COLA
I'm child #3
SQL> SELECT t2.cola, t1.col4
2 FROM t1, t2
3 WHERE t2.col1 = 2
4 AND t2.col2 = 1
5 AND t1.col1 = 2
6 AND t2.col2 = 1;
COLA COL4
I'm child #3 I'm the daddy
I'm child #3 No, I'm the daddy!!
SQL> Caveat emptor
This posting is issued on behalf of the Rogue Moderators. It is posted with the best of intentions but is not guaranteed in any way, shape or form. In particular, the code is presented "as is" and you assume full responsibility for running it on your system. Furthermore, you must not download and install software from the internet unless you know what you are doing and have the permission of whoever owns your system. It was never this hard for the Lone Ranger.Hi,
You can not create unique key with duplicate values as you know. Now if you want to create unique key then you have to delete duplicate records from the table but this again if you can afford to delete because this data may be more importante to you and you can not delete any record.
or you can use ENABLE NOVALIDATE option of oracle explain by Tom on below link.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:8806498660292
or if you dont want to use Tom's way then you go with primary key like
Drop old primary key if there is already on the column.
create new primary key with enable novalidate option. -
Goldengate expects a column that is not in the unique constraint
I do not know golden gate. I am working with a golden gate engineer who doesn't really know oracle. I am the DBA supporting this. This is the issue we are having. Please bare with me if I have trouble explaining it.
I am pulling from oracle and loading to teradata. I confirmed that the unique index is correct in teradata (don't have access. I asked).
Oracle 10.2.0.5
golden gate: 11.1.1.0.29
error: the name of the schema listed in the error is from teradata. So TERADATA_SCHEMA. represents that.
Key column my_id is missing from update on table TERADATA_SCHEMA.MYTABLE
Missing 1 key columns in update for table TERADATA_SCHEMA.MYTABLEbelow is a create table statement. I have altered table and column names. but the structure is the same.
it does NOT have a primary key. It has a unique key. I am not allowed to add a primary key
UNIQUE INDEX: UNIQUE_ID
When we test an updates, golden gate is expecting MY_ID to be sent as well and golden gate abends
The DDL below includes the partitioning/subpartition, unique index, and supplemental logging command that golden gate runs.
I have also run the following 2 commands to turn on supplemental logging:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
ALTER SYSTEM SWITCH LOGFILE;
CREATE
TABLE MYTABLE
"UNIQUE_ID" NUMBER(10,0) NOT NULL ENABLE,
"MY_ID" NUMBER(10,0),
"MYNUMBER" NUMBER(8,0),
"TOTALNUMBER" NUMBER(8,0),
"USED" NUMBER(8,0),
"LOTSUSED NUMBER(8,0),
"LAST_UPDATE_USER" VARCHAR2(30 BYTE),
"LAST_UPDATE_DATE" DATE,
"MYDATESTAMP" DATE,
"MYTYPE" NUMBER(2,0) NOT NULL ENABLE,
"MYTHING" CHAR(1 BYTE) NOT NULL ENABLE
PARTITION BY RANGE
"MYTYPE"
SUBPARTITION BY LIST
"MYTHING"
SUBPARTITION TEMPLATE
SUBPARTITION "MYTHING_X" VALUES
'X'
SUBPARTITION "MYTHING_Z" VALUES
'Z'
PARTITION "MYTHING1" VALUES LESS THAN (2) ,
PARTITION "MYTHING2" VALUES LESS THAN (3) ,
PARTITION "MYTHING3" VALUES LESS THAN (4) ,
PARTITION "MYTHING4" VALUES LESS THAN (5) ,
PARTITION "MYTHING5" VALUES LESS THAN (6) ,
PARTITION "MYTHING6" VALUES LESS THAN (7) ,
PARTITION "MYTHING7" VALUES LESS THAN (8) ,
PARTITION "MYTHING8" VALUES LESS THAN (9) ,
PARTITION "MYTHING_OTHER" VALUES LESS THAN (MAXVALUE)
ALTER TABLE MYTABLE ADD SUPPLEMENTAL LOG GROUP
"MYGROUP_555"
"UNIQUE_ID"
ALWAYS;
CREATE UNIQUE INDEX MY_IND ON MYTABLE (
"UNIQUE_ID"
;Edited by: Guess2 on Nov 3, 2011 12:57 PM
Edited by: Guess2 on Nov 3, 2011 1:21 PMGoldenGate expects a primary key, a unique key, or a list of key columns.
The addition of supplemental logging for the table can be done via SQL, but typically, it is done via the GGSCI interface:
GGSCI 4> dblogin userid <your DB GoldenGate user>, password <your password?
GGSCI 5> add trandata schema_owner.table_name
How Oracle GoldenGate determines the kind of row identifier to useUnless a KEYCOLS clause is used in the TABLE or MAP statement, Oracle GoldenGate selects a
row identifier to use in the following order of priority:
1. Primary key
2. First unique key alphanumerically with no virtual columns, no UDTs, no function-based
columns, and no nullable columns
3. First unique key alphanumerically with no virtual columns, no UDTs, or no function-based
columns, but can include nullable columns
4. If none of the preceding key types exist (even though there might be other types of keys
defined on the table) Oracle GoldenGate constructs a pseudo key of all columns that
the database allows to be used in a unique key, excluding virtual columns, UDTs,
function-based columns, and any columns that are explicitly excluded from the Oracle
GoldenGate configuration.
NOTE If there are other, non-usable keys on a table or if there are no keys at all on the
table, Oracle GoldenGate logs an appropriate message to the report file.
Constructing a key from all of the columns impedes the performance of Oracle
GoldenGate on the source system. On the target, this key causes Replicat to use
a larger, less efficient WHERE clause.
How to specify your own key for Oracle GoldenGate to use
If a table does not have one of the preceding types of row identifiers, or if you prefer those
identifiers not to be used, you can define a substitute key if the table has columns that
always contain unique values. You define this substitute key by including a KEYCOLS clause
within the Extract TABLE parameter and the Replicat MAP parameter. The specified key will
override any existing primary or unique key that Oracle GoldenGate finds.>
"I have altered table and column names. but the structure is the same."
What column name did you alter?
The source table table and target table are either identical, or there must be a source definition file created on the source and copied over to the target and referenced in the replicat.
I don't see why my_id would cause a problem (based on what you posted), unless the tables are different. -
Add a unique constraint on binary XML table
How add a unique constraint of "brevet" field?
The following INSERT failed
SQL Error: ORA-19025: EXTRACTVALUE renvoie la valeur d'un seul noeud
19025. 00000 - "EXTRACTVALUE returns value of only one node"
If the ALTER is made after the INSERT is done, INSERT is valid but ALTER failed with the same error message!
/* copy the file compavions.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<compagnie>
<comp>AB</comp>
<flotte>
<avion immat="F-WTSS" capacite="90">
<typeAv>Concorde</typeAv>
</avion>
<avion immat="F-GFDR" capacite="145">
<typeAv>A320</typeAv>
</avion>
<avion immat="F-GTYA" capacite="150">
<typeAv>A320</typeAv>
</avion>
</flotte>
<nomComp>Air Blagnac</nomComp>
<pilotes>
<pilote>
<brevet>PL-1</brevet>
<nom>C. Sigaudes</nom>
</pilote>
<pilote>
<brevet>PL-2</brevet>
<nom>P. Filloux</nom>
</pilote>
</pilotes>
</compagnie>
in C:\...
--DROP DIRECTORY repxml;
--CREATE DIRECTORY repxml AS 'C:\...';
DROP TABLE pilote_binary_xml5;
CREATE TABLE pilote_binary_xml5 OF XMLType
XMLTYPE STORE AS BINARY XML
VIRTUAL COLUMNS
(col AS (EXTRACTVALUE(OBJECT_VALUE, '/compagnie/pilotes/pilote/brevet')));
ALTER TABLE pilote_binary_xml5 ADD CONSTRAINT brevet_unique UNIQUE (col);
INSERT INTO pilote_binary_xml5 VALUES (XMLType(BFILENAME ('REPXML','compavions.xml'), NLS_CHARSET_ID ('AL32UTF8')));
--ALTER TABLE pilote_binary_xml5 ADD CONSTRAINT brevet_unique UNIQUE (col);You could try something like
(extract(OBJECT_VALUE,compagnie/pilotes/pilote/brevet').getStringVal());
but this is probably unadvisable.
I suggest an alternative is for you to look at XMLINDEX so that you can bring the 'proper' XML functions into play like XMLTABLE etc. -
Error: The user does not exist or is not unique - when setting permission programmatically
Hi,
I am custom Sequential workflow in which I am breaking the permission and setting permission to list item.
I have used the below code for setting Permission:
SPRoleDefinition oSPRoleDefinition = oSPWeb.RoleDefinitions["RoleName"];
//Grant permission to Manager
SPRoleAssignment oSPRoleAssignmentManager = new SPRoleAssignment(strManagerLanID, strManagerEmail, "", "");
oSPRoleAssignmentManager.RoleDefinitionBindings.Add(oSPRoleDefinition);
CurrentListItem.RoleAssignments.Add(oSPRoleAssignmentManager);
I am getting the error as :
Error: The user does not exist or is not unique.
How to fix this?
ThanksI think you misunderstood the solution proposed by frederic, what he is suggesting is that the error doesn't come from your code but from the user account
have you tried with another account ? (maybe the one you are using to log to your environment)
With this information, it will help us to know if the problem comes from your code or from the user account
Best regards, Christopher.
Blog |
Mail
Please remember to click "Mark As Answer" if a post solves your problem or
"Vote As Helpful" if it was useful.
Why mark as answer? -
Tried to add JUnit Test in Eclipse -- "Test type does not exist" error
Hi guys,
I'm developing an assignment whose details I won't bother going into -- it's enough to say that we were introduced to JUnit testing a couple of weeks ago in university tutorials, and I've stupidly tried to add one to my project without fully understanding it all. This is in eclipse 3.1.1.
Basically, I followed eclipse's built-in tutorial called "Writing and running JUnit tests ".
1) Created class "TestFailure" with method "testFailure".
public void testFailure() throws Exception {
fail();
} 2) This then appeared as a .java file in my project (as well as on my UML diagram, courtesy of Omondo's UML plugin).
3) I decided it was too risky mucking around with this stuff in a "live" project, so went ahead and deleted the TestFailure icon on my class diagram.
4) I closed down eclipse.
5) I went ahead and deleted TestFailure.java and TestFailure.class from my project folders.
6) I opened my project again, and tried to execute...
... and now I keep getting a Test type does not exist error when I try and run it.
How on earth do I get rid of this?
Any advice/guidance is greatly appriciated -- oh, how I wish I'd not started messing with JUnit testing!!! :)Um, okay -- I fully hold my hands up and admit that I don't know what I'm doing with JUnit testing (we only had a half hour intro to it) but figured I may as well learn by using the official tutorials. It's always a good place to start! Although obviously using a current assignment isn't the best idea ;)
I was executing my main class (obviously with my main method in there) to execute the program after I'd deleted test case classes, but strangely I've just shut down my machine and restarted and it's working fine. I'm not sure what the deal is here -- lesson learnt though, study new topics on a dummy project! :)
Anyway, if I waited until I understood the software and code I'm producing to its fullest, I think hell'd freeze over before I executed any code! :) Using a tutorial to learn a new aspect of software I'm already familiar with wasn't a bad move, IMHO. Just using it on this particular project was... Needless stress and all that. -
Unique Constraint Not Allowed in OA Table design?
Is it really true or is just my OApps Admin /DBA is just plain stupid for not allowing unique constraint at table level?
I have to implement a EO attribute level validation that does a select on an unindexed field thru the List Validator feature.
The problem is it is taking 40-60 seconds to commit something to the EO.Thats true, if talking about only OAF, you don't need the constraint as you can handle that in code!
--Mukul -
Adding to a task list - User does not exist or is not unique
We have SharePoint 2010 with a single web server front end and another server as the SQL server. When trying to add a task to a list or an announcement to a page, users are getting the error, "The user does not exist or is not unique."
I have searched diligently for an answer, but cannot find anything about this with regards to users getting the error.
Thank you in advance for your assistance.hello,
i have faced your problem few minutes ago. when i was trying to solve another problem
--->> (Object Cache: The super user account utilized by the cache is not configured) --> my current problem
i have found at search results the below PS command to configure super user and super reader.
$w = Get-SPWebApplication http://webapplicationlink
$w.Properties["portalsuperuseraccount"] = "domain account"
$w.Properties["portalsuperreaderaccount"] = "domain account"
$w.Update()
but it caused me another problem which you are facing right now.
---> ( Error: The user does not exist or is not unique)
while adding any item to any list specially lists
then i have tried to rollback by doing the below PS command and it worked and solved it.
$w = Get-SPWebApplication http://webapplicationlink
$w.Properties["portalsuperuseraccount"] = ""
$w.Properties["portalsuperreaderaccount"] = ""
$w.Update()
after that check for the super user and super reader by
Get-SPWebApplication | %{Write-Host "Web Application: " $_.url "`nSuper user: " $_.properties["portalsuperuseraccount"] "`nSuper reader: " $_.properties["portalsuperreaderaccount"] "`n"}
This is the output for the above command should be like this.
Web Application: http://webapplicationlink
Super user:
Super reader:
hope that it helps :)
Karim El Zarka,Senior IT Specialist Commercial International Bank, MCTS Sharepoint -
The "add a device" screen on the desktop does not exist.
The "add a device" screen shown in all the tutorials does not exist on the desktop version of firefox. It is impossible to enter the sync code. There is only a big button "create account" there but i already have an account. The button "conect" generates a code, but there is no way to enter it on the phone. The whole thing is broken and complicated and impossible to understand. Sorry.
Right. The problem is that you need to properly set up Sync.
Click the button there, 'Set up Firefox Sync'. If you don't have an account select 'Create a new Account', otherwise at the bottom, 'I already have a Sync account' -> 'I don't have a device with me' -> complete all details -> continue -- and then you will see the 'Add a device' option in the Sync preferences pane.
The setup is complicated, convoluted and not ideal, and it is being worked on, but that should resolve your issue.
Maybe you are looking for
-
Unable to connect to CMS database during installation
Hi all, Previously when i perform a installation for BOE XI 3.1 on Windows 2003 Server (64 bit) with Oracle 10G 32bit version everything work fine. Now when try to install BOE XI 3.1 on Windows 2003 Server (64 bit) with Oracle 10G 64bit version CMS f
-
IMac 20 inch monitor better than 17 inch?
I'm thinking to buy a iMac (after I had not much luck with a Mini, eg noise). Can anyone advise me on the display. In principal, I would prefer to have a mac with seperate screen, however at the moment the iMac looks the best option to me. From the s
-
Hello, I am getting an error when Posting IDOC type /AFS/ORDERS05 , error is Entry 00 in T173 does not exist - check your entry. I am not sure what this error is , is that some segment not filled correctly from my Z Program. If yes , then what could
-
Directly Printing the Reports Output to a Printer in 10g.
Hi All, We need to print directly from the reports to a printer. How it can be achieved? i.e Reports running in client machine and when I hit the Run Button in my form the report runs. Similarly the report output should be printed to the printer atta
-
Changing download file location in Safari
I want to change the download file location of my safari from the 'default downloads' into my external hard drive. But whenever I tried to change the download location, my external hard drive won't show up under option 'devices' even though it is ins