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 8850073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:48:55+00:00 2026-06-14T12:48:55+00:00

I want to know the Query that allows us to view all the columns

  • 0

I want to know the Query that allows us to view all the columns that are defined for a table in oracle database.

Elaboration:

Table Name: Some_Table have 10 columns.

I want to know how I can retrieve the all column names, their data type, and any constraints that are defined for any column.

  • 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-06-14T12:48:56+00:00Added an answer on June 14, 2026 at 12:48 pm

    I want to know how I can retrieve the all column names, their data type, and any constraints that are defined for any column.

    To do that you can query(depending on privileges granted to you) [user|all|dba]_tab_columns, [user|all|dba]_cons_columns, [user|all|dba]_constraints views.

    Here is a quick example:

     select decode( t.table_name
                  , lag(t.table_name, 1) over(order by t.table_name)
                  , null
                 , t.table_name ) as table_name -- <- just to eliminate 
          , t.column_name                       -- repeated tab_name    
          , t.data_type
          , cc.constraint_name
          , uc.constraint_type
       from user_tab_columns t
            left join user_cons_columns cc
              on (cc.table_name = t.table_name and
                  cc.column_name = t.column_name)
            left join user_constraints uc
              on (t.table_name = uc.table_name and
                  uc.constraint_name = cc.constraint_name )
     where t.table_name in ('EMPLOYEES', 'DEPARTMENTS');
    

    Result:

    TABLE_NAME    COLUMN_NAME       DATA_TYPE      CONSTRAINT_NAME   CONSTRAINT_TYPE
    ------------- ----------------- -------------- -------------------------------
    DEPARTMENTS   LOCATION_ID       NUMBER         DEPT_LOC_FK       R
                  DEPARTMENT_ID     NUMBER         DEPT_ID_PK        P
                  DEPARTMENT_NAME   VARCHAR2       DEPT_NAME_NN      C
                  MANAGER_ID        NUMBER         DEPT_MGR_FK       R
    EMPLOYEES     SALARY            NUMBER         EMP_SALARY_MIN    C
                  PHONE_NUMBER      VARCHAR2                            
                  EMPLOYEE_ID       NUMBER         EMP_EMP_ID_PK     P
                  DEPARTMENT_ID     NUMBER         EMP_DEPT_FK       R
                  JOB_ID            VARCHAR2       EMP_JOB_FK        R
                  MANAGER_ID        NUMBER         EMP_MANAGER_FK    R
                  COMMISSION_PCT    NUMBER                              
                  FIRST_NAME        VARCHAR2                            
                  JOB_ID            VARCHAR2       EMP_JOB_NN        C
                  HIRE_DATE         DATE           EMP_HIRE_DATE_NN  C
                  EMAIL             VARCHAR2       EMP_EMAIL_NN      C
                  LAST_NAME         VARCHAR2       EMP_LAST_NAME_NN  C
                  EMAIL             VARCHAR2       EMP_EMAIL_UK      U
    
    17 rows selected
    

    Also to retrieve a complete specification(if needed) of a table, you can use dbms_metadata package and get_ddl function of that package:

    select dbms_metadata.get_ddl('TABLE', 'EMPLOYEES') as table_ddl
      from dual;
    
     table_ddl
     --------------------------------------------------------------------------------
    
      CREATE TABLE "HR"."EMPLOYEES"
       ("EMPLOYEE_ID" NUMBER(6,0),
        "FIRST_NAME" VARCHAR2(20),
        "LAST_NAME" VARCHAR2(25) CONSTRAINT "EMP_LAST_NAME_NN" NOT NULL ENABLE,
        "EMAIL" VARCHAR2(25) CONSTRAINT "EMP_EMAIL_NN" NOT NULL ENABLE,
        "PHONE_NUMBER" VARCHAR2(20),
        "HIRE_DATE" DATE CONSTRAINT "EMP_HIRE_DATE_NN" NOT NULL ENABLE,
        "JOB_ID" VARCHAR2(10) CONSTRAINT "EMP_JOB_NN" NOT NULL ENABLE,
        "SALARY" NUMBER(8,2),
        "COMMISSION_PCT" NUMBER(2,2),
        "MANAGER_ID" NUMBER(6,0),
        "DEPARTMENT_ID" NUMBER(4,0),
         CONSTRAINT "EMP_SALARY_MIN" CHECK (salary > 0) ENABLE,
         CONSTRAINT "EMP_EMAIL_UK" UNIQUE ("EMAIL")
    
       -- ... other attributes
    
       )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running a query that retrieves 20 rows (for example). I want to know
I want to know number of rows that will be affected by UPDATE query
I know that sp_msforeachtable allows to perform queries on all tables. I have 100
I want to see how many rows my delete query effects so I know
I want to echo the record of a 'select min' query. I know how
I have an android app it displays web view.I want know the app idle
I'm using PDO inside a database abstraction library function query that I've made. I'm
I'm working on page that allows users to edit profile info. I want them
I have 2 tables with the same columns. for example table 1 id name
i want know how i can manage multiple twitter account on iOS in my

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.