0

I am using Oracle. I am trying to view a table that looks like this

OBJECT_NAME         OBJECT_TYPE
-----------------   -----------
DEPARTMENT          TABLE
DEPARTMENT_ID_PK    INDEX
EMPLOYEE            TABLE
EMPLOYEE_ID_PK      INDEX

And this is what I have

SELECT OBJECT_NAME, OBJECT_TYPE
FROM USER_OBJECTS
WHERE OBJECT_NAME IN ('EMPLOYEE', 'DEPARTMENT');

But the table that is printed only shows the Department and Employee object name and types, not the department_id_pk and employee_id_pk. What am I missing?

5
  • Are you using MySQL or Oracle? Commented Nov 9, 2018 at 10:01
  • MySQL <> Oracle. What are you using ? Commented Nov 9, 2018 at 10:01
  • Oracle. my apologies Commented Nov 9, 2018 at 10:02
  • 1
    Try WHERE object_name LIKE 'EMPLOYEE%' OR object_name LIKE 'DEPARTMENT%' Commented Nov 9, 2018 at 10:05
  • @KaushikNayak That worked! Thank you. Commented Nov 9, 2018 at 10:10

1 Answer 1

1

This will work, if you are using naming standards and including the table name in the index and view names:

select
     object_name,
     object_type
from
     user_objects
where
     (object_name like '%EMPLOYEE%') 
OR   (object_name like '%DEPARTMENT%');

If no such standards are followed then you can use,

select 
    b.uniqueness, 
    a.index_name, 
    a.table_name, 
    a.column_name 
  from 
    user_ind_columns a, 
    user_indexes b 
where 
    a.index_name=b.index_name 
  and 
     ((object_name like '%EMPLOYEE%') or (object_name like '%DEPARTMENT%'))
order by 
    a.table_name, 
    a.index_name, 
    a.column_position;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.