ALL_CONSTRAINTS
A view of an all_constraints County printing procedure returns 100 when the copyright procedure and returns 10000 when it is called from an adequate procedure of the Summoner. The owner, the applicant is the same every time. When I looked in the definition of all_constraints, his mark on the basis of schemaid, but my schemaid is the same throughout. What could be the possible reason?create or replace procedure cons
authid definer /current_user ---behaves differently even though the invoker is the owner
as
x number;
begin
select count(1) into x from all_constraints;
dbms_output.put_line(x);
end;
(code}
Thanks
Rahul
Copyright stored procedure runs under the security of the owner of the procedure and does not take into account the roles. That's why he will return constraints without worrying that runs it and will list all the constraints always, owner of the procedure can see via privileges granted directly, without going through role.
Invoker rights of stored procedure runs under the caller's security field and honors roles. Is therefore will list all the constraints of calling procedure can see via privileges both directly and by the role.
So if P1 is rights define stored procedure owned by P2 and U1 is invoker rights stored procedure, when U1 called P2, it may get more constraints that running P1 since U1 can access constraints through roles and P2 will list them while P1 will not.
SY.
Tags: Database
Similar Questions
-
Need to retrieve the names of columns with PK
Hi all
guys I need to get two columns (PK information and secondly with the column name) for the table. I see that's not so easy with Oracle ;(
I have this for now:
SELECT all_tab_cols.column_name,user_constraints.constraint_type FROM all_tab_cols, user_cons_columns, user_constraints,user_ind_columns, user_indexes WHERE all_tab_cols.column_name = user_cons_columns.column_name (+) AND all_tab_cols.table_name = user_cons_columns.table_name (+) AND user_cons_columns.constraint_name = user_constraints.constraint_name (+) AND user_constraints.constraint_type (+) = 'P' AND user_ind_columns.column_name (+) = all_tab_cols.column_name AND user_ind_columns.table_name (+) = all_tab_cols.table_name AND user_indexes.uniqueness (+) = 'UNIQUE' AND user_indexes.index_name (+) = user_ind_columns.index_name AND all_tab_cols.table_name = 'MYTABLE'
but, if KP is then take result duplicate me lines and there is not a simpler way? just need to list all columns of the table with information about the PK
SELECT acc.column_name, ac.constraint_name FROM all_constraints ac, all_cons_columns acc WHERE ac.owner =acc.owner AND ac.constraint_name=acc.constraint_name AND ac.table_name =acc.table_name AND ac.constraint_type='P' AND ac.table_name = 'MY_TABLE' UNION SELECT column_name,NULL FROM all_tab_columns WHERE table_name='MY_TABLE';
-
SqlDevelopper Extension (V4.1.1)
Hello
I'm having a problem, define an extension to V4.1.1 SqlDeveloper: I want to show the chain of tables according to e table of data, here is my 'xml code:
elements <>
< item = "Editor" node vertical = "TableNode" type = "true" >
< title > <! [CDATA [string FK Down]] > < / title >
< query >
< sql > <! [CDATA [with LIST as (select a.CONSTRAINT_NAME, a.TABLE_NAME, B.TABLE_NAME as R_TABLE_NAME
of ALL_CONSTRAINTS a left join B on a.R_CONSTRAINT_NAME = B.CONSTRAINT_NAME ALL_CONSTRAINTS
where a.OWNER =: proprietaire_objet
and a.CONSTRAINT_TYPE = 'R')
Select: OBJECT_NAME of the DOUBLE
Union of all the
Select rpad (' ', (level) * 5) | a.R_TABLE_NAME | '(' || CONSTRAINT_NAME | ')'
the a list
connect nocycle TABLE_NAME = prior R_TABLE_NAME
[[Start by a.TABLE_NAME =: OBJECT_NAME]] > < / sql >
< / query >
< / point >
< / object >
The query gives the result that I wait, but once that I use it as an extension, the rows returned are duplicated 2 or 3 times. Try it with a table with a single CF.
What I am doing wrong? It is very disturbing!
Thanks in advance for your answers
Philippe
PS: Sorry for my bad English
Hello
Thanks for your reply,
I want to display the foreign key chain from a table selected in the browser. Works very well just query and give me exactly what I want, but once defined in an XML file, so it appears as an extension, I get all the duplicate lines.
Starting from a datasheet, I get (for a table TABLE_A with only FK on a TABLE_C without any FK table):
TABLE_A
TABLE_C
Is what I get in the browser when I click on the table is:
TABLE_A
TABLE_C
TABLE_C
TABLE_C
Best regards
Philippe
-
Primary key and foreign key between the different schemas
Hi all;
SCOTT user have a 'rank' of table-> it contains the primary key-> users tablespace
The U1 user have a 'emp' table-> it contains the foreign key-> test tablespace
U1 > select constraint_name, constraint_type, r_owner, owner, r_constraint_name of all_constraints where table_name = 'EMP ';
OWNER CONSTRAINT_NAME C R_OWNER R_CONSTRAINT_NAME
------------ ------------------------------ - -------------------------- ----------------------- -----------------------------------------------------
U1 EMP_EMPLEV_C12_FK R SCOTT GRADE_GRL_C1_PK
If I have connection U1, no possibility to find the name of the primary key without connection scott table?
Thank you
Hello
So, you want to know what picture of the SCOTT schema has the constraint that is named "GRADE_GRL_C1_PK." Isn't it?
If so,.
SELECT table_name
Of all_constraints
Owner WHERE = 'SCOTT '.
AND the argument constraint_name = 'GRADE_GRL_C1_PK. '
;
-
dbms_xmlgen. GetXml with single quotes
Can you get it someone please let me know what is wrong with this query. I try to convert the long and CLOB type. I wanted to convert long to varchar2 and to do this, I am to convert the long to clob or varchar2 clob.
The query works fine when doing a rownum = 1 in the dynamic query but I would like to read carefully all the constraints so tried the underside and its failure with an error message for an unexpected end of SQL command.
-with rownum
SELECT dbms_lob.substr (longtoclob, 4000, 1) text
of the double.
(select (dbms_xmlgen.getxml ("SELECT t.search_condition ALIASLONG
OF All_Constraints t WHERE rownum = 1')) longtoclob
the double) Y where DBMS_LOB. GETLENGTH (Y.longtoclob) > 0;
-generic query
Select (SELECT (dbms_xmlgen.getxml (Q'[select search_condition in all_contstaints where cosntraint_name = ']' | constraint_name |))) Q '[']')) text, constraint_name from
ALL_CONSTRAINTS
where rownum < = 3;
-generic query
Select (SELECT (dbms_xmlgen.getxml (Q'[select search_condition in all_contstaints where cosntraint_name = ']' | constraint_name |))) Q '[']')) text, constraint_name from
ALL_CONSTRAINTS
where rownum<>
'A few' bad stuff here:
-keyword SELECT extra
-typos in names of objects
-DBMS_XMLGEN.getXML will give you a CLOB that represents a dataset XML to canonical format, not the search_condition directly necessary
It is more what you are looking for, but know it's slow:
select constraint_name , xmlcast( dbms_xmlgen.getxmltype( 'select search_condition from all_constraints where constraint_name = ' || dbms_assert.enquote_literal(constraint_name) ) as varchar2(4000) ) as text from all_constraints where rownum <= 3 ;
(XMLCAST is 11g only, use the extractValue on lower versions)
-
How can I disable all table constraints
Hi all
I use Oracle SQL Developer
I am trying to disable all constraints of tables so I can truncate the tables.
That's what I came with, but it does not work. Can someone help me please.
Thanks in advance,
Kevin
Start
for news (select fk.owner, fk.constraint_name, fk.table_name
of all_constraints fk, pk all_constraints
where fk. Constraint_type = 'R' and
PK. Owner = "EIFILTERED" and
FK.r_owner = pk.owner and
FK. R_CONSTRAINT_NAME = pk. Constraint_name and
PK. TABLE_NAME = 'ADDRESS', 'ALTERNATENAME', 'ACTIVITY', 'CASEEVENT.
) loop
run immediately ' ALTER TABLE ' ' |. ' cur. Owner: ' "."' | cur.table_name |' "FORCED TO CHANGE" "|" " cur.constraint_name |' "DISABLE";
end loop;
end;
Hello
Try this;
Start
for news (select fk.owner, fk.constraint_name, fk.table_name
of all_constraints fk, pk all_constraints
where fk. Constraint_type = 'R' and
PK. Owner = "EIFILTERED" and
FK.r_owner = pk.owner and
FK. R_CONSTRAINT_NAME = pk. Constraint_name and
PK. Table-name in ('ADDRESS', 'ALTERNATENAME', 'ACTIVITY', 'CASEEVENT'( )
) loop
run immediately ' ALTER TABLE ' ' |. ' cur. Owner: ' "."' | cur.table_name |' "FORCED TO CHANGE" "|" " cur.constraint_name |' "DISABLE";
end loop;
end;
HTH,
Pradeep
-
Oracle 10g convert N column with the command lines.
SQL > USER to see THE
VEERA
SQL > create table test (number n, fname varchar2 (10), the number of age (10), sal number (10));
Table created.
SQL > ALTER TABLE TEST ADD CONSTRAINT PK_TEST PRIMARY KEY (N, FNAME, AGE);
Select
table_name,
RTrim (xmlagg (xmlelement (e, column_name |))) ') .extract ('/ / text()'), ',') COLUMN_NAME
(SELECT ACC. TABLE_NAME, VAC. COLUMN_NAME
OF ALL_CONSTRAINTS ACN, VAC ALL_CONS_COLUMNS
WHERE THE VAC. TABLE_NAME = 'TEST '.
AND ACN. CONSTRAINT_TYPE = 'P '.
AND ACN. CONSTRAINT_NAME = ACC. CONSTRAINT_NAME
AND ACN. OWNER = ACC. OWNER
AND ACN. OWNER = 'VEERA '.
)
Table_name group
/
TABLE_NAME COLUMN_NAME
------------------------------ ----------
TEST N, AGE, FNAME
I have need of NAME of COLUMN must be of the order of position_colonne. [N, FNAME, AGE].
Please tell us how can I get the result. Is this possible using CASE or also DECODE the number of constraints are unknown.
Kind regards
Veera.
Select
table_name,
RTrim (xmlagg (xmlelement (e, column_name |))) ') order of position) .extract ('/ / text()'), ',') COLUMN_NAME
(SELECT ACC. TABLE_NAME, VAC. Column_name, acc.position
OF ALL_CONSTRAINTS ACN, VAC ALL_CONS_COLUMNS
WHERE THE VAC. TABLE_NAME = 'TEST '.
AND ACN. CONSTRAINT_TYPE = 'P '.
AND ACN. CONSTRAINT_NAME = ACC. CONSTRAINT_NAME
AND ACN. OWNER = ACC. OWNER
AND ACN. OWNER = 'VEERA '.
)
Table_name group
/
-
Hello, everyone.
I have a file that I need to remove in a table, but I don't know if there are any related tables that might break if I just delete the record.
Is there a way to determine if / what tables are related? Can I use SQL Developer.
V/r,
JD
And you won't see it directly. Query I posted shows the relationship between the constraints, not tables. So, if you want to check if table TBL scheme S has children tables:
SELECT *.
OF ALL_CONSTRAINTS
WHERE)
R_OWNER,
R_CONSTRAINT_NAME
))
SELECT THE OWNER
CONSTRAINT_NAME
OF ALL_CONSTRAINTS
WHERE OWNER = S"
AND TABLE_NAME = 'TBL '.
)
/
SY.
-
How to find child every column foreign keys of tables without index {worm 10 g}
Hi Experts,
I have need of a query to find child all the foreign keys of table columns, which are not having an index on the foreign key column.
Try this.
SELECT T1. OWNER,
T1. CONSTRAINT_NAME,
T1. TABLE_NAME,
T2. COLUMN_NAME,
T1. CONSTRAINT_TYPE
OF ALL_CONSTRAINTS T1,.
ALL_CONS_COLUMNS T2
WHERE T1. CONSTRAINT_NAME = T2. CONSTRAINT_NAME
AND T1. TABLE_NAME = T2. TABLE-NAME
AND T1. OWNER = T2. OWNER
AND T1. CONSTRAINT_TYPE = 'R '.
AND T2. COLUMN_NAME NOT IN (SELECT COLUMN_NAME FROM ALL_IND_COLUMNS T WHERE TABLE_NAME = T1.) TABLE_NAME AND COLUMN_NAME = T2. COLUMN_NAME);
Post edited by: Parth272025
-
Why my function returns nothing when I create as a schema object
I have the ABC's of the user who owns several paintings, some of which have foreign key constraints.
I have user XYZ who has access to all the tables belonging to the user ABC.
When I create a user XYZ feature to use more I get no return when I run:
Select XYZ.ztm_tables_depended_on ('ABC', 'A_TABLE_OWNED_BY_ABC') of double:
Please see after the function definition.
CREATE or REPLACE FUNCTION ZTM_TABLES_DEPENDED_ON (p_Owner VARCHAR2, nom_table_p VARCHAR2) RETURN VARCHAR2 IS
CURSOR C1 IS
SELECT CONSTRAINT_NAME, OWNER, R_CONSTRAINT_NAME, R_OWNER
OF ALL_CONSTRAINTS
WHERE OWNER = p_Owner
AND TABLE_NAME = nom_table_p
AND CONSTRAINT_TYPE = 'R '.
ORDER BY OWNER, CONSTRAINT_NAME, R_OWNER, R_CONSTRAINT_NAME;
--
v_Referenced_Owner VARCHAR2 (31);
v_Ret_Val VARCHAR2 (4000);
--
The FUNCTION CONSTRAINT_TABLE_NAME(p_Owner VARCHAR2, p_Constraint_Name VARCHAR2) RETURN VARCHAR2 IS
CURSOR C1 IS
SELECT TABLE_NAME
OF ALL_CONSTRAINTS
WHERE OWNER = p_Owner
AND the argument CONSTRAINT_NAME = p_Constraint_Name;
--
v_Ret_Val ALL_CONSTRAINTS. TABLE_NAME % TYPE;
BEGIN
OPEN C1;
FETCH C1 INTO v_Ret_Val;
CLOSE C1;
--
RETURN v_Ret_Val;
END;
--
BEGIN
FOR R IN C1 LOOP
IF (R.OWNER <>R.R_OWNER) THEN v_Referenced_Owner: = R.R_OWNER | '.';
ANOTHER v_Referenced_Owner: = NULL;
END IF;
--
v_Ret_Val: = v_Ret_Val | ', ' || v_Referenced_Owner | CONSTRAINT_TABLE_NAME (R.R_OWNER, R.R_CONSTRAINT_NAME);
END LOOP;
--
RETURN LTRIM (v_Ret_Val, ',');
END;
/
But if I enter the function within an anonymous block as follows, I get results:
DECLARE
CURSOR C1 IS
Select owner, table_name
From all_tables where owner = 'ABC ';--
The FUNCTION ZTM_TABLES_DEPENDED_ON(p_Owner VARCHAR2, p_Table_Name VARCHAR2) RETURN VARCHAR2 IS
CURSOR C1 IS
SELECT CONSTRAINT_NAME, OWNER, R_CONSTRAINT_NAME, R_OWNER
OF ALL_CONSTRAINTS
WHERE OWNER = p_Owner
AND TABLE_NAME = nom_table_p
AND CONSTRAINT_TYPE = 'R '.
ORDER BY OWNER, CONSTRAINT_NAME, R_OWNER, R_CONSTRAINT_NAME;
--
v_Referenced_Owner VARCHAR2 (31);
v_Ret_Val VARCHAR2 (4000);
--
The FUNCTION CONSTRAINT_TABLE_NAME(p_Owner VARCHAR2, p_Constraint_Name VARCHAR2) RETURN VARCHAR2 IS
CURSOR C1 IS
SELECT TABLE_NAME
OF ALL_CONSTRAINTS
WHERE OWNER = p_Owner
AND the argument CONSTRAINT_NAME = p_Constraint_Name;
--
v_Ret_Val ALL_CONSTRAINTS. TABLE_NAME % TYPE;
BEGIN
OPEN C1;
FETCH C1 INTO v_Ret_Val;
CLOSE C1;
--
RETURN v_Ret_Val;
END;
--
BEGIN
FOR R IN C1 LOOP
IF (R.OWNER <>R.R_OWNER) THEN v_Referenced_Owner: = R.R_OWNER | '.';
ANOTHER v_Referenced_Owner: = NULL;
END IF;
--
v_Ret_Val: = v_Ret_Val | ', ' || v_Referenced_Owner | CONSTRAINT_TABLE_NAME (R.R_OWNER, R.R_CONSTRAINT_NAME);
END LOOP;
--
RETURN LTRIM (v_Ret_Val, ',');
END;--
BEGIN
FOR R IN C1 LOOP
DBMS_OUTPUT. Put_line (ztm_tables_depended_on (R.Owner, R.Table_Name));
END LOOP;
END;
/Any ideas what is happening here?
Any ideas what is happening here?
Justin said the likely reason.
See the section "How to exercise roles in PL/SQL blocks" the doc of database security for details
http://docs.Oracle.com/CD/E25054_01/network.1111/e16543/authorization.htm#i1007304
Operation of the roles in PL/SQL blocks
The use of roles in a PL/SQL block depends on if it is an anonymous block, or a block named (stored procedure, function, or trigger), and if it runs with the rights of the author or the rights of the applicant.
Roles used in the appointed with rights to define blocks
All roles are disabled in any PL/SQL block named (stored procedure, function, or trigger) that runs with the rights of the author. Roles are not used to privilege control, and you cannot define roles within the procedure of a DEFINER rights.
The
SESSION_ROLES
view shows all roles that are currently enabled. If a named PL/SQL block that runs with Definer Rights queriesSESSION_ROLES
, then the query will return no rows.Roles used in blocks named with the rights of the plaintiff and anonymous PL/SQL
Named PL/SQL blocks that run with the rights of the applicant and the anonymous PL/SQL blocks are executed at the end of the privileges granted through active roles. Current roles are used for verification within rights Summoner of privilege the PL/SQL block. You can use dynamic SQL statements to define a role in the session.
See this line beginning by "all roles are disables in any PL/SQL block named"?
-
Find the name and the table constraint type based on the name of the field
I have a field name or a column with me... I want to find the name of the table is a primary key... Any request to make this work so that the running costs are low...
Currently, I mix dba_constraints and ALL_TAB_COLUMNS to get this... is possible to extract the data of a process cost effective single table/any other is appreciated
You must include the USER/ALL_CONSTRAINTS with USER/ALL_CONS_COLUMNS to achieve your desired results. For your specific condition, you can try this query.
Select constraint_name
column_name
de)
Select c.constraint_name
cc.column_name
count on column_count (c.constraint_name score) (cc.column_name)
from user_constraints c
Join user_cons_columns cc
on c.constraint_name = cc.constraint_name
where constraint_type = 'P '.
)
where column_name = 'EMPNO '.
and column_count = 1;
I used USER_CONSTRAINTS and USER_CONS_COLUMNS. If you use ALL or DBA dictionary table add join OWNER condition as well.
-
primary key of a synonym in Oracle
Can we all know how I can describe a table to get the table structure and relationships. Relationships in the sense which column is used as a primary key and a foreign key in a particular table.
DESC table provides details of the column. I executed under query, but it gives only the following points.
award_reason / / DESC
Name of Type Null
--------------- -------- ------------
AWARD_REASON_ID NOT NULL NUMBER (11)
REASON_TYP NOT NULL VARCHAR2 (35)
SORT_ORDR NOT NULL NUMBER (2)
ASSETS NOT NULL NUMBER (1)
Here 'award_reason' is a synonym.
Can someone help me on this please.
Here is a list of dictionary tables which have details on CONSTRAINTS.
SQL > select table_name dictionary where table_name like ' % CONSTRAINT % ';
TABLE-NAME
------------------------------
DBA_CONSTRAINTS
DBA_IAS_CONSTRAINT_EXP
ALL_CONSTRAINTS
USER_CONSTRAINTSSQL > select table_name dictionary where table_name like 'CONS\_COL% %' escape ' \';
TABLE-NAME
------------------------------
DBA_CONS_COLUMNS
ALL_CONS_COLUMNS
USER_CONS_COLUMNS -
Hi guys,.
I am trying to execute the following statement
UPDATE DOCSADM. FORMSTYLES
STYLE = '"U" + STYLE N' GAME
WHERE 22192063 > AND < 22192574 SYSTEM_ID SYSTEM_ID
but getting the following strange error while there is no single constratint on the column.
Error from the 1 in the command line:
UPDATE DOCSADM. FORMSTYLES
STYLE = '"U" + STYLE N' GAME
WHERE 22192063 > AND < 22192574 SYSTEM_ID SYSTEM_ID
Error report:
SQL error: ORA-00001: unique constraint (DOCSADM. FORMSTYLESC) violated
00001 00000 - "forced single (s.%s) violated."
* Cause: An UPDATE or INSERT statement attempted to insert a duplicate key.
For Trusted Oracle configured in DBMS MAC mode, you can see
This message if there is an entry double at a different level.
* Action: Either remove the single restriction or not to insert the key.
Any idea?You can see ALL_CONSTRAINTS and ALL_INDEXES. (If you have access to DBA_ * views)
To prove your statement - "there is no unique constraint on the column.
-
Hello
I want to have the details as the tablename, volumn name of foreign key to a table of reference.
Using this query, I get everything except the column name for reference.SELECT a.column_name, c_pk.table_name r_table_name, c_pk.constraint_name r_pk FROM all_cons_columns a JOIN all_constraints c ON a.owner = c.owner AND a.constraint_name = c.constraint_name JOIN all_constraints c_pk ON c.r_owner = c_pk.owner AND c.r_constraint_name = c_pk.constraint_name WHERE c.constraint_type = 'R' AND a.table_name = :TableName
Can someone please help?
ThanxYou must add another join to ALL_CONS_COLUMNS:
SELECT a.column_name, c_pk.table_name r_table_name, c_pk.constraint_name r_pk, c_pk_c.column_name FROM all_cons_columns a JOIN all_constraints c ON a.owner = c.owner AND a.constraint_name = c.constraint_name JOIN all_constraints c_pk ON c.r_owner = c_pk.owner AND c.r_constraint_name = c_pk.constraint_name JOIN all_cons_columns c_pk_c ON c_pk_c.owner = c_pk.owner AND c_pk_c.constraint_name = c_pk.constraint_name WHERE c.constraint_type = 'R' AND a.table_name = :TableName
-
forced to deleted still apply the constraint
I have a two-column table that has a couple of constraints which is to keep the pair of these two unique columns. When I insert the first record (the table is empty), I get the constraint violation. I wouldn't have this error. Disabling the constraint does not help so I remove the constraint. Now I can insert that record, but when I try to insert the same record, I this violation with the name of the deleted constraint.
Here is the result: (the deleted constraint is EQ_FOR_QUOTE_HAZ_HAZMAT_RFQ)
SQL> delete from req_for_quote_haz;
Any ideas?
1 row deleted.
SQL> commit;
Commit complete.
SQL> select constraint_name from all_constraints where table_name='REQ_FOR_QUOTE_HAZ';
CONSTRAINT_NAME
------------------------------
REQ_FOR_QUOTE_HAZ_HAZMAT_ID_FK
SQL> insert into REQ_FOR_QUOTE_HAZ values (1815,1);
1 row created.
SQL> insert into REQ_FOR_QUOTE_HAZ values (1815,1);
insert into REQ_FOR_QUOTE_HAZ values (1815,1)
*
ERROR at line 1:
ORA-00001: unique constraint (ITS.REQ_FOR_QUOTE_HAZ_HAZMAT_RFQ) violated
SQL>
Thank you
ViewPerhaps you have a unique index on the columns. If not can you confirm that you are looking in HIS scheme.
Maybe you are looking for
-
Right does not work in split view
A lot of times when I use split view, my split screens, but my Web pages do not go in their half of the screen and when I try to escape SV, it won't let me. My screen is half lit up, I can still use my Web pages, but I can't in my office (the bar at
-
Can I restore pictures of my generation Ipod 5th damaged by water?
I need help immediately. I used my 5th GEN Ipod with the hands wet and noticed that he quickly extinguished on me that I was using. As soon as I got home I placed in rice for over 24 hours and tried to turn it on but nothing happened. I even tried to
-
There seems to be a problem with Windows Media Player
Windows Media Center does not work correctly. The screen turns off, and I can't go out there, just put on tab Whats going on?
-
My better half is not in computer science and has no desire to become. I have too many movies and want to set up my HTPC as a giant DVD player only. I load movies and play movies. What are the absolute minimum services required for windows 7 to run (
-
How do force you a T410 to recognize wifi networks?
How do force you a T410 to recognize wifi networks? I have a t410 that my company has released me. Works fine at the office on a wired network. But I can't take anywhere and use wifi. The only network he displays when you click the network icon in