Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6349525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:38:01+00:00 2026-05-24T21:38:01+00:00

Can i find out if a column is a primary or foreign key through

  • 0

Can i find out if a column is a primary or foreign key through Oracle’s ALL_TAB_COLS view?

select * 
from all_tab_cols 
where table_name = 'ALL_TAB_COLS'
;

1   SYS ALL_TAB_COLS    OWNER   VARCHAR2            30          N   1       <Long>                                  CHAR_CS 30  NO  NO      30  B   NO  YES NO  NO  1   1
2   SYS ALL_TAB_COLS    TABLE_NAME  VARCHAR2            30          N   2       <Long>                                  CHAR_CS 30  NO  NO      30  B   NO  YES NO  NO  2   2
3   SYS ALL_TAB_COLS    COLUMN_NAME VARCHAR2            30          N   3       <Long>                                  CHAR_CS 30  NO  NO      30  B   NO  YES NO  NO  3   3
4   SYS ALL_TAB_COLS    DATA_TYPE   VARCHAR2            106         Y   4       <Long>                                  CHAR_CS 106 NO  NO      106 B   NO  YES NO  NO  4   4
5   SYS ALL_TAB_COLS    DATA_TYPE_MOD   VARCHAR2            3           Y   5       <Long>                                  CHAR_CS 3   NO  NO      3   B   NO  YES NO  NO  5   5
6   SYS ALL_TAB_COLS    DATA_TYPE_OWNER VARCHAR2            30          Y   6       <Long>                                  CHAR_CS 30  NO  NO      30  B   NO  YES NO  NO  6   6
7   SYS ALL_TAB_COLS    DATA_LENGTH NUMBER          22          N   7       <Long>                                          NO  NO      0       NO  YES NO  NO  7   7
8   SYS ALL_TAB_COLS    DATA_PRECISION  NUMBER          22          Y   8       <Long>                                          NO  NO      0       NO  YES NO  NO  8   8
9   SYS ALL_TAB_COLS    DATA_SCALE  NUMBER          22          Y   9       <Long>                                          NO  NO      0       NO  YES NO  NO  9   9
10  SYS ALL_TAB_COLS    NULLABLE    VARCHAR2            1           Y   10      <Long>                                  CHAR_CS 1   NO  NO      1   B   NO  YES NO  NO  10  10
11  SYS ALL_TAB_COLS    COLUMN_ID   NUMBER          22          Y   11      <Long>                                          NO  NO      0       NO  YES NO  NO  11  11
12  SYS ALL_TAB_COLS    DEFAULT_LENGTH  NUMBER          22          Y   12      <Long>                                          NO  NO      0       NO  YES NO  NO  12  12
13  SYS ALL_TAB_COLS    DATA_DEFAULT    LONG            0           Y   13      <Long>                                  CHAR_CS 0   NO  NO      0       NO  YES NO  NO  13  13
14  SYS ALL_TAB_COLS    NUM_DISTINCT    NUMBER          22          Y   14      <Long>                                          NO  NO      0       NO  YES NO  NO  14  14
15  SYS ALL_TAB_COLS    LOW_VALUE   RAW         32          Y   15      <Long>                                          NO  NO      0       NO  YES NO  NO  15  15
16  SYS ALL_TAB_COLS    HIGH_VALUE  RAW         32          Y   16      <Long>                                          NO  NO      0       NO  YES NO  NO  16  16
17  SYS ALL_TAB_COLS    DENSITY NUMBER          22          Y   17      <Long>                                          NO  NO      0       NO  YES NO  NO  17  17
18  SYS ALL_TAB_COLS    NUM_NULLS   NUMBER          22          Y   18      <Long>                                          NO  NO      0       NO  YES NO  NO  18  18
19  SYS ALL_TAB_COLS    NUM_BUCKETS NUMBER          22          Y   19      <Long>                                          NO  NO      0       NO  YES NO  NO  19  19
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:38:02+00:00Added an answer on May 24, 2026 at 9:38 pm

    No – you can’t since this information is not part of that view, see http://download.oracle.com/docs/cd/B13789_01/server.101/b10755/statviews_1179.htm

    To find out the primary key column(s) of a table see http://www.techonthenet.com/oracle/questions/find_pkeys.php – the information is in the Views all_constraints + all_cons_columns .

    To find foreign key information try:

    SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
    FROM all_constraints cons, all_cons_columns cols
    WHERE cons.constraint_type = 'R'
    AND cons.constraint_name = cols.constraint_name
    ORDER BY cols.table_name, cols.position;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I find out which column and value is violating the constraint? The
How can I find out the default value of a column in a table
How can i find out if a column exists in a DataReader's results set?
Can somebody tell me how I can find out how many threads are in
simple question: How I can find out commands for a DLLImport in C#.Net and
Can anyone tell me how I can find out if an SPField object is
I know I can find out if a variable is null in Java using
I can't seem to understand how I can find out what is erroring out
Is there any way I can find out in my app if the user
Is there a way that I can find out how many matches of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.