Select the data in user_cons, user_constraints, user_cons_columns

Dear Sirs, I want to select the name of the table and its referential tables and constraint_names and column used in this referencial constraints
I use this selection, but it doesn't look good
Select t.table_name, t.ref_name, c.constraint_name, m.column_name
of user_cons t, user_constraints c, user_cons_columns m
where
c.table_name = t.table_name
and m.table_name = c.table_name
and m.constraint_name = c.constraint_name
and constraint_type = 'R '.
and c.table_name like '% STK '.
order of table_name, constraint_name


Please help me
Yasser

Yasser,

Try this SQL.

SELECT A.TABLE_NAME CHILD_TABLE_NAME, D.TABLE_NAME MASTER_TABLE_NAME, A.CONSTRAINT_NAME CHILD_CONSTRAINT_NAME, A.R_CONSTRAINT_NAME MASTER_CONSTRAINT_NAME, C.COLUMN_NAME CHILD_COLUMN, D.COLUMN_NAME MASTER_COLUMN
FROM USER_CONSTRAINTS A, USER_CONS_COLUMNS C, USER_CONS_COLUMNS D
WHERE A.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND A.R_CONSTRAINT_NAME = D.CONSTRAINT_NAME AND A.TABLE_NAME LIKE 'STK%'
ORDER BY A.TABLE_NAME, A.CONSTRAINT_NAME

Kind regards

Manu.

If my answer or the answer to another person has been useful or appropriate, please mark accordingly

Published by: Manu. April 27, 2010 15:19

Tags: Oracle Development

Similar Questions

  • Select the data in a table and update in another table

    Dear experts,

    create the table TB_ENCRYPT

    (

    Identification number,

    Varchar2 (200) KEY

    );

    INSERT INTO TB_ENCRYPT VALUES(1,'HJUVHDUIFBSDGVU');

    SELECT * FROM TB_ENCRYPT;

    1 HJUVHDUIFBSDGVU

    create TABLE users)

    username, NUMBER of

    password VARCHAR2 (200)

    );

    Insert users

    values (1, 123 # "")

    Insert users

    values (2, 456 #')

    Select * from users;

    1 123 #.

    # 2 456

    I want to select the data KEY for table TB_ENCRYPT column and update in the column of tables for the respective key user password

    TB_ENCRYPT table contains only a single key value. Comparing this key, I want to update the old value of the key to the new value.

    For encryption and decryption I followed the java class method.no is worried about that.

    create or replace

    PACKAGE PCK_ENC AUTHID CURRENT_USER AS

    FUNCTION DECRYPT (VARCHAR arg0, arg1 VARCHAR) AS VARCHAR BACK LANGUAGE JAVA NAME 'Encrclass.decrypt (java.lang.String, java.lang.String) return java.lang.String ';

    FUNCTION ENCRYPT (VARCHAR arg0, arg1 VARCHAR) AS VARCHAR BACK LANGUAGE JAVA NAME 'Encrclass.encrypt (java.lang.String, java.lang.String) return java.lang.String ';

    END;

    SELECT PCK_ENC. ENCRYPT('1234','HJUVHDUIFBSDGVU') FROM DUAL;

    HERE,

    1234 - is the password of the users table column data

    HJUVHDUIFBSDGVU - represents the key of table TB_ENCRYPT column data.

    Comparing this key, I want to update the old value of the key to the new value.

    I tried with this method

    declare

    cursor c1 is

    Select the key

    of TB_ENCRYPT

    where id = 1

    update the id;

    Start

    for c1_rec looping c1

    update users

    password is PCK_ENC. Encrypt (Password, Key)

    the location being c1;

    commit;

    end loop;

    end;

    /

    Help, please

    You can use the MERGE statement.

    merge into users
    using tb_encrypt
       on (id = userid)
      when matched then
          update set password = PCK_ENC.ENCRYPT(password,key);
    

    And why you encrypt your password. This isn't a good idea. Just password hash.

  • outer join while selecting the date max

    Hello
    Oracle 11g R2.

    I want to build a query that joins outside between 2 related tables, but selects only the date max if more than 1 record returned for a given customer. Here are the tables I and some records.

    create table customer (NumCli number, name varchar2 (100))
    create table orders (ordnum number, NumCli number, date orddate)

    insert into customers values (1, 'ABC')
    insert into customer values (2, 'DEF')
    insert into customer values (3, 'ABC')
    insert into customer values (4, 'DEF')

    insert into orders values (1, 1, sysdate)
    insert into orders values (2, 1, sysdate + 1)
    insert into orders values (3, 2, sysdate + 2)

    I created the following query, but it returns the two dates for NumCli = 1. I want to display the name of the client no matter if he has a prescription. But if there is more order, I want display the folder with the date max.

    Select a.custnum, b.SID, b.orddate
    client a, b of orders
    where a.custnum = b.custnum (+)
    and b.orddate (+) < = sysdate + 10 - additional criteria as part of the edition

    It is a simplified example of a more complex query, that I am trying to solve. If possible, could you please suggestion a request without the use of analytical functions or inline views?
    Thank you!!

    Published by: arizona9952 on April 4, 2013 22:05

    arizona9952 wrote:
    Thanks Jac. Any way to do this without a group of?

    Is there a particular reason not to use MAX?

    It will be difficult to find a maximum date without a group of... If it's ok for you to have everything available, you can use the correlated sub query...

    select a.custnum, a.name,
             (
               select b.orddate
               from   orders b
               where b.custnum = a.custnum
               and b.orddate <= sysdate + 10
               and rownum = 1 ) ordddate
    from customer a
    
  • How to select the data that meet multiple criteria

    name load_date
    -------- ----------------
    Smith 11/02/2010
    John 01/10/2009
    Cindy 03/04/2010
    Smith 03/10/2010


    I want to select all names including load_date exist in February AND March.

    Expected results: -.

    Smith

    I can use the intersect operator to get all the names that were given in February AND March by using the following query.

    Select the name of the table where to_char ("load_date, ' FMMonth YYYY") = "February 2010"»
    intersect
    Select the name of the table where to_char ("load_date, ' FMMonth YYYY") = "March 2010"»


    Y at - it an easier way to retrieve the same data that is similar to the use group by, having cluase etc?

    Thanks in advance.

    Hello

    You can do it in one pass through the table with GROUP BY and HAVING:

    SELECT       name
    FROM       table_x
    WHERE       load_date     >= DATE '2010-02-01'     -- First date inside target range
    AND       load_date     <  DATE '2010-04-01'     -- First date OUTSIDE target range
    GROUP BY  name     -- not TRUNC (load_date, 'MONTH')
    HAVING       COUNT (DISTINCT (TRUNC (load_date, 'MONTH')))     = 2
    ;
    

    Try to keep the columns indexed by themselves in comparisons; in this way, you can use indexes.
    For example, if there is an index on load_date, then the above query could use, as load_date is only on one side of the > = or<>
    A similar State

    where   to_char (load_date, 'FMMonth YYYY') = 'February 2010'
    

    cannot use an index on load_date, because we do not compare load_date - we compare the results of TO_CHAR (load_date,...).

    Published by: Frank Kulash, April 13, 2010 16:44
    Fixed GROUP BY clause

  • SELECT the data inserted into a global temporary Table in a stored proc

    A stored procedure is run from Oracle SQL Developer to insert data into a global temporary table. A SQL (in Oracle SQL Developer) worksheet is open to run a SELECT query to retrieve the data from the temporary table overall which was populated in the stored procedure. No row is returned. I guess it's because the stored procedure and the SELECT statement executed in different sessions.

    Is it possible to run the stored procedure in Oracle SQL Developer and then execute a select statement on the temporary table overall which was filled in the stored procedure by using the same connection so that the data can be extracted?

    I use version 1.5.1 build HAND-5440 of Oracle SQL Developer.

    In a worksheet, do something like

    Start
    insert_proc;
    end;

    Select * from my_temp_table;

    Place the cursor on each statement in turn and Press f9 (where it all began... the end is a single statement.

  • Select the data if a value has a certain value?

    Hello, I'm trying to do...


    In pseucode, it looks like to...

    If this field has a value, then select a, b, c,... of table
    another "don't do anything".

    How can I do that, I tried...

    Select decode (LKP2. EXCLUDED_BOOK_CD, not null,
    (select 1 double),
    ('NOT NULL', 'ALL')
    OF LKP2 fcl_chunk_pid_correspondence
    WHERE LKP2. CHUNK_ID =: p_chunk_id
    AND LKP2. GCDS_ENTITY = "TRANSACTION".
    AND LKP2. EXCLUDED_BOOK_CD IS NOT NULL
    AND LKP2. UBR = "OTHER";

    But this does not work if there is not any row for where.

    Thanks in advance!

    write a case statement as

    Select the case while sal is not null, then end of sal from emp;

  • Numbers automatically selects the "date format" for cells.

    Numbers automatically format selects 'date' of certain cells.

    I need "numbers."

    I want to calculate simple interest due on the amount, the interest rate and number of days.

    When I input "number" format of the result cell and calculate the amount * rate * number of days divided by 365 always automatically shows something unwanted and the format "date." Furthermore, I'm not able to change the AutoFormat ("date") in "number".  How to bypass this automatic selection?

    Thanks in advance

    UbiUbu

    Maybe you can share what, exactly, you enter in a cell.  A screenshot is also useful.

    Here's a way to do what I think you want:

    Enter amounts in cells B1, B2 and B3

    Select cell B6, and type (or copy and paste it here) the formula:

    =B2*B3*B1/365.25/100

    shortcut for this is:

    B6=B2*B3*B1/365.25/100

  • Select the date of

    Hello

    We command 'Select Date' in the front panel control palette, when you click that opens in windows "Set Date and time".

    Is it possible to call the "Set Date and time" window without using the control date selection.

    Thanks and greetings

    Rohith M P

    cancancanopen wrote:

    But to my knowledge, I wanted to know where in the LabVIEW 'Date and time Set' directory will be available.

    The VI is called "picktime.vi" and it is located in the directory "\resource\dialog".

  • Select the data in a time

    Hello

    I'm new to OBIEE and I'm struggling with something.

    I have two columns, one is all filled with dates and other numbers.

    I just wanto to select only numbers since just last month. How can I add this filter?

    Thank you

    Ah!

    If your condition is much easier

    "since just last month" for me what it wanted to say from the 1st to the last day of the previous month.

    Yes, you got it right with "timestampadd (SQL_TSI_MONTH,-1, current_date)" be aware that it does not mean "last 30 days".

    When you're in March he will be only 28 or 29 days (if 29 Feb there exists this year) and the same months have 31 days.

  • Select the data from collections plsql

    Hi all

    I'm not a developer but working as a DBA, so not very familiar with pl/sql, always crossed with documentation and could lead to a solution of my problem. I need advice from expert here.

    Problem: I am writing in a kind of special program plsql for surveillance of certain lots, I know that we have much option to do the same db/grid control including... etc but for some
    the reason I have to do this, use only plsql.

    Requirement: my requirement is to select data in the plsql table and then have the opportunity to ask questions again and again. I prefer not to go to table, rather than directly from plsql...

    I wrote below the code for the sample, bulk data in collection type collection and can print using the loop.

    Declare
    TS type is table v$ session % rowtype index by pls_integer;
    tsess ts.
    Start
    Select * bulk collect into tsess from v$ session;
    I'm looping 1.tsess.count
    dbms_output.put_line (tsess (i) .terminal);
    end loop;
    end;
    /

    But is it possible same collection (tsess in the example above) can be queried using a select as ' select * from table (Tsess) "I searched the net and found this can be done using create type at the database level.» But my problem is that I can't create any object in the database as being it's a production one.

    I was looking as if is it possible even can be accomplished... as cast / multiset... However, I could not get it through.

    your help would be appreciated!

    Kind regards

    I don't think you should use the tables here, only SQL, take a look at the factors of subquery and will indicate if it is not enough...

    Published by: BrendanP on February 12, 2012 03:07 for an example:

    I understand you want to "Refresh" of data that you already have the database purely to be able to use the SQL such as ORDER BY in multiple ways. Here's how you can do it in the original SQL for a particular example, where you query v$ sql time control processor and disk reads separately (I tested it but the result won't be good look here, so omitting it):

    WITH v AS (
    SELECT
        Substr (sql_text,1,500)             sql_text,
        cpu_time/1000000                    cpu_seconds,
        disk_reads,
        buffer_gets,
        executions,
        CASE WHEN rows_processed != 0 THEN Round( buffer_gets / Nvl (Replace (rows_processed, 0, 1) ,1)) END Buffer_gets_rows_proc,
        Round (buffer_gets / Nvl (Replace (executions, 0, 1), 1)) Buffer_gets_executions,
        elapsed_time / 1000000              elapsed_second,
        module
    FROM v$sql s)
    SELECT
        'CPU'                order_by,
        cpu_seconds          order_val,
        sql_text,
        cpu_seconds,
        disk_reads,
        buffer_gets,
        executions,
        buffer_gets_rows_proc,
        buffer_gets_executions,
        elapsed_second,
        module
    FROM v
     UNION
    SELECT
        'Disk reads',
        disk_reads,
        sql_text,
        cpu_seconds,
        disk_reads,
        buffer_gets,
        executions,
        buffer_gets_rows_proc,
        buffer_gets_executions,
        elapsed_second,
        module
    FROM v
    ORDER BY order_by, order_val DESC
    
  • SQL - select the data with the nearest past date

    Hello
    I have a requirement to retrieve data based on a closer effective_date in the past.
    Here are examples of data

    Data in the table

    DESCRIPTION OF ARTICLE EFFECTIVE_DATE
    ---------------------------------------------------------------------------
    018885237 24 OCTOBER 09 DVD + R 47 10 PK
    DISC OF DVD + R 10 018885237 16 APRIL 10

    040706113 FLASH PLAYER 24 OCTOBER 09
    040706113 4 March 10 Micro USB 4 GB
    040706113 13 January 10 Flash drive 4 GB

    032140640 26 FEBRUARY 10 8 GB USB
    032140640 24 OCTOBER 09 8 GB FLASH

    The power required

    DESCRIPTION OF ARTICLE EFFECTIVE_DATE
    ---------------------------------------------------------------------------
    DISC OF DVD + R 10 018885237 16 APRIL 10
    040706113 4 March 10 Micro USB 4 GB
    032140640 26 FEBRUARY 10 8 GB USB

    Can someone help me with the SQL please?

    Concerning
    Harsha
    SQL> --- generating sample  data:
    SQL> with t as (
      2  select 018885237 item, to_date('24-OCT-09', 'dd-mon-yy') effective_date, 'DVD+R 47 10 PK' description from dual unio
      3  select 018885237, to_date('16-APR-10', 'dd-mon-yy'), 'DVD+R 10 DISC' from dual union
      4  select 040706113, to_date('24-OCT-09', 'dd-mon-yy'), 'FLASH DRIVE' from dual union
      5  select 040706113, to_date('04-MAR-10', 'dd-mon-yy'), '4GB USB Micro' from dual union
      6  select 040706113, to_date('13-JAN-10', 'dd-mon-yy'), 'Flash Driv 4GB' from dual union
      7  select 032140640, to_date('26-FEB-10', 'dd-mon-yy'), '8GB USB' from dual union
      8  select 032140640, to_date('24-OCT-09', 'dd-mon-yy'), '8GB FLASH' from dual
      9  )
     10  --
     11  -- actual query
     12  --
     13  select  item
     14  ,      effective_date
     15  ,      description
     16  from ( select item
     17         ,      effective_date
     18         ,      description
     19         ,      row_number() over (partition by item order by effective_date desc)  rn
     20         from   t
     21       )
     22  where rn=1;
    
          ITEM EFFECTIVE DESCRIPTION
    ---------- --------- --------------
      18885237 16-APR-10 DVD+R 10 DISC
      32140640 26-FEB-10 8GB USB
      40706113 04-MAR-10 4GB USB Micro
    
  • Select the data in two tables

    Hello

    I am trying to build a query WITH, but I can't seem to make it work:

    WITH P1 AS (SELECT OT_VALUE

    OF CSD_OPEN_VERY_HIGH_INCIDENTS VHIGH

    WHERE OT_VALUE > = 0

    ). P2 AS (SELECT OT_VALUE

    OF HIGH CSD_OPEN_HIGH_INCIDENTS

    WHERE OT_VALUE > = 0

    ), SELECT VHIGH. OT_VALUE, TOP. OT_VALUE

    P1 P2 JOIN INTERNALLY. RATING = P2. RANKING

    The two tables have the same column names.

    I want to only return a set of results if the two columns (OT_VALUE) contain in reality 1.

    Select this check box. This is a job for all four images. This will return the line to the following combinations. 0.0 and 0.1 and 1.0 and 1.1. Importance is 1.2.  Let me know if you face any problem

    SELECT CASE WHEN ((VH_OT_VAL = 0 ET H_OT_VAL = 0) OR (VH_OT_VAL = 1 AND H_OT_VAL = 0) OR (VH_OT_VAL = 0 AND H_OT_VAL = 1) or (VH_OT_VAL = 1 AND H_OT_VAL = 1)) 1

    ANOTHER ACE OF NULL TERMINATOR OT_VAL

    DE)

    SELECT H.OT_VALUE H_OT_VAL,

    VH. OT_VALUE VH_OT_VAL

    OF CSD_OPEN_VERY_HIGH_INCIDENTS VH.

    CSD_OPEN_HIGH_INCIDENTS H

    WHERE NVL (VH. CLASSIFICATION, 0) = NVL(H.CLASSIFICATION,0)

    AND VH. IMPORTANCE IN (1,2)

    AND H.IMPORTANCE IN (1,2)

    AND NVL (VH. OT_GROUP, 0) = NVL(H.OT_GROUP,0)

    AND VH. IMPORTANCE = H.IMPORTANCE

    AND VH. TIME_STAMP = H.TIME_STAMP

    );

  • Select the data on the different data source

    Hello

    There is a Web Application of merger with a Module of the Application that is based on the "database server 1".

    For the calculation of the values of database 1, I need to get data (Table DB) '2 database server.

    How to get values (Table) database 2 in the same project?

    (I must have a second Module of Application maybee?)

    Thank you for advice.

    I suggest to have several app module with in your template project. Suppose appmod1 for "Database Server 1" and appmod2 for "database 2" server.
    I did the same thing in my application and it works very well.

    ~ Abhijit

  • How can I dynamically select the shared Variable API programming data type?

    I am trying to create a configuration of open connections of variable shared using the programming API. It seems to me that the cleanest way to do would be to put one "open and check" routine in a loop, then call it for each variable in the library.

    The question that I am running is that I have different types of data in my library (to help a server Modbus i/o and data types 'boolean' and 'single' in my library.) How can I dynamically select the data type of the shared variable API?

    See the attached snipit.

    Thank you

    What I ended up doing was doing a Subvi to open, read, write, and close each data type, I use the packaged in 4 polymorphic SubVIs (polymorphic Open, read, etc...)

    Now all I have to do I drop in the polymorphic Subvi and it switches automatically to the appropriate data type

  • Selection of data in the table in a table

    I use apex 3.2

    I have a report where he returnts say 3 rows.


    I need to select data from a table in and table and then use the data in this table in a body of email

    or select the data in the table and use the data in the body of the sub form of e-mail

    How can I do this. ?

    something like below

    Empno name e-mail address
    1 XX [email protected]
    2 bb [email protected]
    3 [email protected] aa

    Hello

    You can take the values in the table in the cursor and use it in the part of the email.
    It will be like,

    Cursor c1 is
    Select Empno, emp email;

    In the part of the body

    Hardcode the values of the columns inside html tags

    l_body: = '

    ';

    I'm in c1
    loop
    l_body: = l_body | »

    ';
    end loop;
    l_body: = l_body | »
    EmpNo
    i.EmpNoi.Namei.email
    ';

    then use the variable 'l_body' inside your share email.

    I hope this helps.

    Kind regards
    LIBERATOR

Maybe you are looking for

  • recover photos from opening crash

    People, I did a huge Boo - Boo, and I don't know how I did it. Somehow, somehow, I managed to get ALL of my photos in trash opening (which was previously populated, incidentally, with photos that I actually * wanted * to the trash). I need them, with

  • With the help of Windows Vista Edition family and unable to connect to the Netgear router.

    No matter what patches I try, I still, I get a message error "settings saved on this computer for the network do not match the requirements of the network. Two other latops under Xp and Windows 7 connect perfectly.  The user called Geeksquad who told

  • ASA 5500 x IPS license to the license of firepower

    I recently attended a webcast Cisco and told me that it is possible to obtain a free migration since the IPS license inherited the firepower license if you have a 5500 Series x ASA.  Nobody is able to successfully get the free conversion?

  • BlackBerry 10 password remove for development mode

    Is it possible to be in development mode and have not created a password? Z10 is my primary phone, and it annoys me that I have the password on every time I'm in development mode. I'll be in dev without password mode? It would be a little easier my l

  • Laptop Pavilion 15 TS: currently downgraded to win 8.1 x 64 to win Pro 8.0 x 64

    Hi Please help: I use a laptop HP Pavilion Touchsmart 15: Intel Core i7-4500U CPU @1. 8 GHz 2.40 GHz 8 GB RAM dedicated graphics processor from nVidia GeForce 2 Go I demoted currently 8.1 to win x 64 win 8.0 Pro x 64 bit. I'm having a problem install