Howto check all tables if have unique key
I need to check all tables if they have unique key. If they do not i must print it.
How can i make this in PL/SQL
regards
But dba_constraints is not storing the information when i establish a unique constraint by creating unique index.
SQL> create table t as select level no from dual connect by level <= 10
2 /
Table created.
SQL> create unique index t_idx on t(no)
2 /
Index created.
SQL> select distinct table_name
2 from user_indexes
3 where uniqueness = 'UNIQUE'
4 and table_name = 'T'
5 /
TABLE_NAME
T
SQL> select * from dba_constraints where constraint_type = 'U' and table_name = 'T'
2 /
no rows selected
SQL> select * from dba_constraints where table_name = 'T'
2 /
no rows selected
SQL> select * from user_constraints where table_name = 'T'
2 /
no rows selected
SQL>But on the other hand user_indexes has it in all case
SQL> drop table t
2 /
Table dropped.
SQL> create table t(no number unique)
2 /
Table created.
SQL> select distinct table_name
2 from user_indexes
3 where uniqueness = 'UNIQUE'
4 and table_name = 'T'
5 /
TABLE_NAME
T
SQL> select * from dba_constraints where table_name = 'T'
2 /
OWNER CONSTRAINT_NAME C TABLE_NAME SEARCH_CONDITION
R_OWNER R_CONSTRAINT_NAME DELETE_RU
STATUS DEFERRABLE DEFERRED VALIDATED GENERATED BAD RELY LAST_CHAN INDEX_OWNER INDEX_NAME INVALID VIEW_R
ELATED
SYSADM SYS_C00391103 U T
ENABLED NOT DEFERRABLE IMMEDIATE VALIDATED GENERATED NAME 02-SEP-08 SYSADM SYS_C00391103Thanks,
Karthick.
Similar Messages
-
How to check the tables we have created in JDBC??
I have created a table called COFFEE2 in a datasource called temp which is in SQL server...How to check the table values??
i went into administrative tools and odbc cource then i could see the data source i have created but how to see the table??
Can anyone help??
thanxHmm.. not sure that I understand the problem.
Call getConnection on the DataSource, and then execute the select query on the connection.
Kaj -
Copying tables that have Foreign Keys
All my tables are using primary/foreign keys. If you look at the example below, I have a table 'stu_school' which has 3 foreign keys (FK_YEAR,FK_SCHOOL,FK_GRADE_LEVEL) pointing to 3 other tables. Every year I need to create a new record in the year table and copy the data from the previous year (with the FK_YEAR value) into the new year. Is there a better approach to moving this data over other than manually writing SQL statements and making sure they are done in the correct order (becuase of the keys).
stu_school
PK_ID
FK_YEAR
FK_SCHOOL
FK_GRADE_LEVEL
year
PK_ID
YEAR
school
PK_ID
SCHOOL
grade_level
PK_ID
FK_YEAR
FK_SCHOOL
GRADE_LEVELSince this is going to be an annual task and should therefore be part of the application I suggest writing a pl/sql script that performs the necessary actions rather than use sql to generate the sql to perform the action. A pl/sql script would allow better activity logging and error handling appropriate for a repeating production task.
IMHO -- Mark D Powell -- -
ADF: To define the TopLink Table should have Primary Key
Hi,
Just I want to know prerequiste to define the TopLink based on JavaObjects from tables.
Regards
BabuHi,
Just I want to know prerequiste to define the TopLink based on JavaObjects from tables.
Regards
Babu -
Problems Engineering Surrogate Primary Key with Unique Key
SDDM 3.3.0.747 with 2 problems (at least so far). I am hoping that the problem is with this SDDM rookie and I have overlooked some setting. PROBLEM 1 I don’t want to start a religious debate about surrogate vs. natural keys but I am having a problem engineering both correctly from the logical model. I am a rookie when it comes to SDDM but have many years of experience with Designer. By default I like to have both a natural UID (UK) and a surrogate key based primary UID (PK) which is used for foreign keys. The problem I am having with engineering is I can successfully engineer the surrogate PK’s, engineer the FK’s using the PK’s but cannot get the unique key to contain the surrogate keys in the child table. If I check the identifying property in the relations, the PK columns and the UK columns are included in the child PK and the UK contains no columns. The Setup I have defined two reference entities, PROBABILITY and SEVERITY with natural unique keys defined. I also have a child entity RISK_ASSESMENT with relationships back to the PROBABILITY and SEVERITY entities and both have the “Use surrogate keys:”: check box checked. The unique key for the RISK_ASSESMENT entity includes the relationships back to PROBILITY and SEVERITY. None of the entities have a PK or surrogate key defined and they all have the “Create Surrogate Key” check box checked. In addition the following preferences are set: Data Modeler/Model/Logical NOT Checked - Use And Set First Unique Key As Primary Key NOT Checked – Name – Keep as the name of the Originating attribute Checked – Entity Create Surrogate Key Checked – Relationship Use Surrogate Key PROBLEM 2 When the foreign key columns are engineered I want the names to have a prefix “FK_” but they don’t. Templates are set as follows: Data Modeler/Naming Standard/Templates Foreign Key: FK_{child}{parent} Column Foreign Key: FK_{ref column} Engineer to Relational Model/General Options Checked - Apply name translation Marcus Bacon
I have been switching between SD 4 EA1 and SDDM 3.3 trying to get things to work and trying out the template table for adding audit columns (really nice!).
Concerning Problem1. No matter what settings I use and whether I use SDDM 3.3 or SDI cannot get the FK columns to be included in the UK even though the relations are included in the UID in the entitty. When I open the properties of the child table and click on the naming standards button and click ok it complains that the UK is not complete. I add the FK columns to the UK and all is well including the naming standards.
Concerning Problem 2. Sometimes it engineers the names for FK's from the template and sometimes it doesn't. Didn't see a pattern. Gave up trying and used Naming Standards button. I still had to change a few.
The good new is, that after make changes needed in UK's and Column names of 18 tables, I know have everything deployed to Test except FK Indexes. I think I have to do those by hand.
Marcus Bacon -
Need to test if a column have unique values or not
Hi all,
in ETL process I need to check if some cols have unique values or not using sql or plsql.
Suppose we need to load a big file data with external table initially and then test if values
on one or more columns have unique values in order to proceed with ETL process.
What is the faster test I can execute to verify that a column have unique values or not?
It's better for the ETL performance, use:
a. techniques regard constraints like described on Ask tom forum
"ENABLE NOVALIDATE validating existing data"
(Ask Tom &quot;ENABLE NOVALIDATE validating existing da...&quot;)
b. "simply" query on the data?
like this:
select count(count(*)) distinct_count,
sum(count(*)) total_count,
sum(case when count(*) = 1 then 1 else null end) non_distinct_groups,
sum(case when count(*) > 1 then 1 else null end) distinct_groups
from hr.employees a
group by A.JOB_ID
c. use analytics function?
d. use some feature directly on external table?
Bye in advanceHere is the example to handling the errrs using LOG_ERRORS into concept. You will check this and let me know if any doubt you have
DATAFILE:-
1000,ANN,ZZ105
1001,KARTHI,ZZ106
1002,PRAVEEN,ZZ109
1002,PARTHA,ZZ107
1003,SATHYA,ZZ108
1000,ANN,ZZ105
----- Original Table With unique constraints
SQL> CREATE TABLE tab_uniqtest(student_id NUMBER(10) UNIQUE,
student_name VARCHAR2(15),
course_name VARCHAR2(15)
2 3 4
Table created.
----- External table
SQL> CREATE TABLE tab_extuniqtest(student_id NUMBER(10),
2 student_name VARCHAR2(15),
3 course_name VARCHAR2(15)
4 )
5 ORGANIZATION EXTERNAL
6 (
7 DEFAULT DIRECTORY ann_dir
8 ACCESS PARAMETERS
9 (
10 RECORDS DELIMITED BY NEWLINE
11 BADFILE 'tabextuniqtest_badfile.txt'
12 LOGFILE 'tabextuniqtest_logfile.txt'
13 FIELDS TERMINATED BY ','
14 MISSING FIELD VALUES ARE NULL
15 REJECT ROWS WITH ALL NULL FIELDS
16 (student_id,student_name,course_name)
17 )
18 LOCATION ('unique_check.csv')
19 )
20 REJECT LIMIT UNLIMITED;
Table created.
---- Error logging table to log the errors
SQL> CREATE TABLE dmlerrlog_uniqtest(ORA_ERR_NUMBER$ NUMBER ,
2 ORA_ERR_MESG$ VARCHAR2(2000),
3 ORA_ERR_ROWID$ ROWID,
4 ORA_ERR_OPTYP$ VARCHAR2(2),
5 ORA_ERR_TAG$ VARCHAR2(4000),
6 inserted_dt VARCHAR2(50) DEFAULT TO_CHAR(SYSDATE,'YYYY-MM-DD'),
7 student_id VARCHAR2(10)
8 );
Table created.
---- Procedure to insert from external table
SQL> CREATE OR REPLACE PROCEDURE proc_uniqtest
2 AS
3 v_errcnt NUMBER;
4 BEGIN
5 INSERT INTO tab_uniqtest
6 SELECT * FROM tab_extuniqtest
7 LOG ERRORS INTO dmlerrlog_uniqtest('PROC_UNIQTEST@TAB_UNIQTEST') REJECT LIMIT UNLIMITED;
8 SELECT COUNT(1) into v_errcnt
9 FROM dmlerrlog_uniqtest
10 WHERE ORA_ERR_TAG$ = 'PROC_UNIQTEST@TAB_UNIQTEST';
11 IF(v_errcnt > 0) THEN
12 ROLLBACK;
13 ELSE
14 COMMIT;
15 END IF;
16 DBMS_OUTPUT.PUT_LINE ( 'Procedure PROC_UNIQTEST is completed with ' || v_errcnt || ' errors') ;
17 EXCEPTION
18 WHEN OTHERS THEN
19 RAISE;
20 END proc_uniqtest;
21 /
Procedure created.
SQL> SET SERVEROUTPUT ON
SQL> EXEC proc_uniqtest;
Procedure PROC_UNIQTEST is completed with 2 errors
PL/SQL procedure successfully completed.
SQL> SELECT STUDENT_ID,ORA_ERR_MESG$ FROM dmlerrlog_uniqtest;
STUDENT_ID ORA_ERR_MESG$
1002 ORA-00001: unique constraint (
SCOTT.SYS_C0037530) violated
1000 ORA-00001: unique constraint (
SCOTT.SYS_C0037530) violated -
Strange Unique Key Error When Copying Cube
I have an empty cube (cube2) I checked it many times. I am copying data from cube1 using an info package. In Info Package I set delete option, i.e., delete existing data in cube2 before loading.
As soon as loading starts, I get a short dump with error message:
An entry was to be entered into the table |
"\FUNCTION=RSAR_ODS_GET\DATA=L_TH_ISOSMAP" (which should have
had a unique table key (UNIQUE KEY)).
However, there already existed a line with an identical key.
The insert-operation could have occurred as a result of an INSERT- or
MOVE command, or in conjunction with a SELECT ... INTO.
The statement "INSERT INITIAL LINE ..." cannot be used to insert several
| initial lines into a table with a unique key.
I tried other cubes, same error occurs. I checked on SN, people have encountered this error but solution is not posted. Any idea, how can I get rid of the error.
Thanks a lot.Hi
Try to load from Cube1 to cube2 without using that option and see if it loads. If that works then add an extra step on the
process chain ' Delete overlapping requests from the target ' after the infopackage load .
Thanks
Jay. -
Cannot create DDL for Unique Key
I have a relational model with a unique key constraint. When I go to Export -> DDL File for my model, and look at the PK and UK constraints tab for "DDL Generation Options", the UK is checked. But upon inspecting the generated DDL file, it is not being generated! The target database in Oracle 11.1 and I am using DM 4.0.3.853.
Hi,
Very strange. Is there anything unusual about the Table or its Unique Key column(s)?
Is everything else being generated as expected?
Are there any relevant error messages in the log? (You can use External Log on the View menu to display the log.)
David -
Primary/Unique key for GL_IMPORT_REFERENCES
Hi all,
We are on EBS11.5.10. I have the following requirement. I need to put a snapshot log on GL_IMPORT_REFERENCES which we will use to interface data to out reporting environment. Therefore i need to set a primary key on GL_IMPORT_REFERENCES, this is required for creating the snapshot log.
Can anyone suggest what combination of fields would be unique for this table, as no unique key is set.
TIAmma,
but do you tie them in with ETL? or they're simply uniqe auto-number-like?
Thanks
I just found this:
http://datawarehouse.ittoolbox.com/groups/technical-functional/informatica-l/re-about-oracle-bi-and-fact-tables-and-image-tables-1515935
Looks like there's a new methodology for extending the DWH. I'm still looking into this, but I still think auto-numbering ROW_WID is a good idea.
Mma, perhaps - could you provide me with an example or two to present this change. Thanks -
ORA-1779?? (I have unique index defined)
I execute the query:
UPDATE
(select rec.cod_instalacion_marca cod_instal_marca_RECLAMAC, ins.cod_instalacion_marca cod_instal_marca_DIM_INST_MAR
from ods.RECLAMAC rec
INNER JOIN master_dwh.DIM_MODELOS mod ON (rec.cod_modelo = mod.cod_modelo)
INNER JOIN master_dwh.DIM_INSTAL_MARCAS ins ON (rec.taller_implicado = ins.cod_instalacion and mod.cod_marca = ins.cod_marca))
SET cod_instal_marca_RECLAMAC = cod_instal_marca_DIM_INST_MAR
And I received the error:
ORA-01779: cannot modify a column that maps to a non-key preserved column
But I have:
*) Primary key in the field: ins.cod_instalacion_marca (table: master_dwh.DIM_INSTAL_MARCAS)
*) Unique Key in the fields: ins.cod_instalacion + ins.cod_marca (table: master_dwh.DIM_INSTAL_MARCAS).
How can I solve it???
Thanks very much!Iâm sorry,
But the table RECLAMAC is the table I want to modify!!! I canât define unique key in this field (rec.cod_instalacion_marca ) because is the field that I want to modify and the values could repeat and that is correct.
I read for example the AskTom Followup:
You NEED a primary key/unique constraint on object_id in T1 to ensure that each row in T joins to AT MOST 1 row in T1.
Consider, if T had:
OBJECT_NAME OBJECT_ID
ABC xxxx
and T1 had:
OBJECT_NAME OBJECT_ID
ABC 123
ABC 456
what should be the outcome of:
ADHOC@VOYAGER> update
2 (select t.object_id toid,t1.object_id t1oid
3 from t,t1
4 where t.object_name=t1.object_name
5 and upper(t.object_name)='PRIMARY_SALESFORCE')
6 set toid=t1oid;
should T have 123 or 456 and under what circumstances? Since the outcome of
that update is 100% AMBIGOUS, we do not permit it. We need to ensure key
preserved-ness and do that with a primary key/unique constraint.
You need that index anyway typically for performance.
But my T1 table in the AskTom example is DIM_INSTAL_MARCAS and I have defined the unique key: ins.cod_instalacion + ins.cod_marca
Look at this:
If I create the field cod_marca in the table RECLAMAC and execute this query, it is executed OK!!!!!!
UPDATE
(select rec.cod_instalacion_marca cod_instal_marca_RECLAMAC, ins.cod_instalacion_marca cod_instal_marca_DIM_INST_MAR
from ods_clientes.EXP_RECLAMACIONES_EXPEDIENTES rec
INNER JOIN maestros_dwh.DIM_INSTALACIONES_MARCAS ins ON (rec.taller_implicado = ins.cod_instalacion and rec.cod_marca = ins.cod_marca))
SET cod_instal_marca_RECLAMAC = cod_instal_marca_DIM_INST_MAR
But if I execute:
UPDATE
(select rec.cod_instalacion_marca cod_instal_marca_RECLAMAC, ins.cod_instalacion_marca cod_instal_marca_DIM_INST_MAR
from ods.RECLAMAC rec
INNER JOIN master_dwh.DIM_MODELOS mod ON (rec.cod_modelo = mod.cod_modelo)
INNER JOIN master_dwh.DIM_INSTAL_MARCAS ins ON (rec.taller_implicado = ins.cod_instalacion and mod.cod_marca = ins.cod_marca))
SET cod_instal_marca_RECLAMAC = cod_instal_marca_DIM_INST_MAR
I receive the error ORA-01779: cannot modify a column that maps to a non-key preserved column
I NEED IT...
What unique index I have to create?
Thanks very much! -
Checkbox (check all) in interactive report behaves not as expected.
I have created an interactive report with one column being apex_item.checkbox (1,key,checking_expression).
To be able to check all rows, I have put the following code in the column's heading field:
<input type="checkbox" onclick="checkAll(this)" value="1" name="x01"/> (code got with Firebug from automatically generated tabform).
Well, the checkbox in heading checks/unchecks itself OK, but then, instead of checking all rows, a standard interactive column menu drops with sort/select value options.
I presume, I am missing something. But what?
IgorLooking with Firebug at at the generated code, I see the following:
div id="apexir_SEL_YON" style="text-align: center;" onclick="gReport.controls.widget(this.id)"
<input type="checkbox" name="x01" value="1" onclick="checkAll(this)"/>
/div
How could I patch away this onclick trigger?
Igor
Edited by: kortchnoi on Sep 2, 2008 12:11 PM -
How to manage unique key ?
My table has a unique key ... but OWM prevents version enabling
of a table which has a unique key.
Before version enabling the unique key means: a same value
cannot be used twice.
After version enabling it should mean: a same value cannot be
used twice at the same time .
How to manage such a situation ?
Thank you.Workspace Manager currently does not support versioning of tables
that contain unique constraints. There is some confusion in
defining what is unique in a multi-version system. Is it unique
in a branch of versions or does it have to be unique in the
entire system?
We plan to address this in the next release. In the meantime, we
welcome your suggestions. Also, I am interested in knowing the
application context in which you are using Workspace Manager.
thanks
Arun -
Check if table, column exist in large database
Dear All!
I'm writing a perl script in which I use database manipulation (for Oracle), with the DBI module.
How can I check whether a given table name is exists in a large database. The command:
select table_name from user_tables where table_name =' name I look for'
always returns 0. I doesn' t work for me.
If I use select * from "my table name" : how it operates with the memory, because of the *
command?
Is there any way, that from the table (which existence I try check) I select a random column or the first one. ?
thank you!!
nagybalyTry instead of USER_TABLES:
select table_name from ALL_TABLES where table_name =' name you look for'USER_TABLES only examines the tables in your personal schema, ALL_TABLES examines all tables you have privileges against.
-cf -
Hi,
While setting up goldengate i have come accross the following error in the error log. This error occurs when extract in started.
2010-08-06 18:53:58 INFO OGG-00476 Oracle GoldenGate Capture for Oracle, ext-a.prm: Gathering metadata for [SEND.SOURCE] not successful even though object was resolved, retrying [3] times with 1 second interval.
2010-08-06 18:53:59 WARNING OGG-00455 Oracle GoldenGate Capture for Oracle, ext-a.prm: Problem in resolving [SEND.SOURCE]: OCI error (904-ORA-00904: "VISIBILITY": invalid identifier) building query to fetch unique key, SQL < SELECT key.key_name, key.column_name, key.descend FROM (SELECT c.constraint_name key_name, c.column_name column_name, c.position position, >, try to fix this issue in order to avoid possible fatal error.
2010-08-06 18:53:59 INFO OGG-00476 Oracle GoldenGate Capture for Oracle, ext-a.prm: Gathering metadata for [SEND.SOURCE] not successful even though object was resolved, retrying [2] times with 1 second interval.
2010-08-06 18:54:00 WARNING OGG-00455 Oracle GoldenGate Capture for Oracle, ext-a.prm: Problem in resolving [SEND.SOURCE]: OCI error (904-ORA-00904: "VISIBILITY": invalid identifier) building query to fetch unique key, SQL < SELECT key.key_name, key.column_name, key.descend FROM (SELECT c.constraint_name key_name, c.column_name column_name, c.position position, >, try to fix this issue in order to avoid possible fatal error.
2010-08-06 19:07:13 ERROR OGG-00521 Oracle GoldenGate Capture for Oracle, ext-a.prm: Object was resolved, however in the same resolution call both DDL history and database metadata resolution failed, cannot recover, SCN [489507], object id [51514].
note that my table does contain unique key
Any ideas? Stuck at this stage :(
thanks
SalmanHi Dominik
I managed to correct that one. It was actually the name of my trails are different on primary node and remote node.
Now i am attempting to configure bidirectional traffic but during this phase the repilcat 1 dies (abending).
Log shows up as follows
2010-08-06 21:42:21 INFO OGG-00996 Oracle GoldenGate Delivery for Oracle, rep-a.prm: REPLICAT REP-A started.
2010-08-06 21:42:21 WARNING OGG-01004 Oracle GoldenGate Delivery for Oracle, rep-a.prm: Aborted grouped transaction on 'RECV.DEST', Database error 100 (retrieving bind info for query).
2010-08-06 21:42:21 WARNING OGG-01003 Oracle GoldenGate Delivery for Oracle, rep-a.prm: Repositioning to rba 1653 in seqno 1.
2010-08-06 21:42:21 WARNING OGG-01154 Oracle GoldenGate Delivery for Oracle, rep-a.prm: SQL error 1403 mapping SEND.SOURCE to RECV.DEST.
2010-08-06 21:42:21 WARNING OGG-01003 Oracle GoldenGate Delivery for Oracle, rep-a.prm: Repositioning to rba 1653 in seqno 1.
2010-08-06 21:42:21 ERROR OGG-01296 Oracle GoldenGate Delivery for Oracle, rep-a.prm: Error mapping from SEND.SOURCE to RECV.DEST.
2010-08-06 21:42:21 ERROR OGG-01668 Oracle GoldenGate Delivery for Oracle, rep-a.prm: PROCESS ABENDING. -
hi Friends ,i need a suggestion from you on how to
insert data to all tables on a Database "A " on Test server
Select data from all tables on a Database "A" on Production Server
where id=123
Database A is same with Structures on Test and Production also all Tables will have Id column in common.
The purpose of this insert is ,as we all know Production has the latest data and i need to push to test server on request for particular ID only ( may be weekly once or twice a week )
I have a linked server setup name "LINQ"
Example for one table is below , like wise i need a script which does for 154 tables.
Insert into ABC( id, name)---insert to test server
Select Id, name from LINQ.ProdSerevrname.databasename.ABC where id = 123
Please help me ..
ThanksWhy not use export import wizard for this if you've read access to production?
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page
Maybe you are looking for
-
BPS: Planning with Non-Cumulative KF
Hi All, i'm trying to implement Headcount Planning and to do this i'm thinking to use a non-cumulative KF (Headcount) with delta cumulative KF (Hiring and Dismissal). The user should plan the delta cumulative KF. I would like to know if this is possi
-
What can I do, if a DVD will not play?
What can I do, if a DVD will not play?
-
Intuos4 tablet won't work when iMac wakes from sleep
Whenever my iMac wakes from sleep my Intuos4 tablet no longer functions (I use it in place of my Magic Mouse). Has anyone had this issue?
-
Error message on 4500 switch please help me rectify this issue .
LLog Buffer (4096 bytes): valid source MAC address (00:00:00:00:00:00) on port Gi2/1 in vlan 1 4d15h: %C4K_L2MAN-6-INVALIDSOURCEADDRESSPACKET: (Suppressed 2 times)Packet recei
-
My new voice-over software won't read Adobe PDF files
I am using Adobe Reader X 10.1.10 and the Latest Voice Over software on my new Mac Mini! I use Voice-Voice-over software to help me read faster and the earlier adobe and voice-voice-over software worked great. The voice-over software is working wit