0

I am trying to get all the column data in a table. For example I have a table called User and it has 2 columns name, hobby.

By running an sql query I want the following info.

name type=varchar2 length=50
hobby type=varchar2 length=100

Is there an SQL query that can be run to obtain this information? I am only able to find queries which tries to fetch the length of largest data in the column. But I want to get the actual length the column has been setup.

Using Datagrip but due to my read only access in production environment, I am not able to see the values in tree view. Please assist. Thanks.

Popeye
  • 35,427
  • 4
  • 10
  • 31
karvai
  • 2,417
  • 16
  • 31
  • 1
    I am assuming you are using Oracle database. Check the following question: https://stackoverflow.com/questions/13448860/how-to-view-all-the-metadata-of-columns-of-a-table-in-oracle-database – geldek Nov 21 '19 at 10:13

3 Answers3

0

If you are running in ORACLE prompt you can disperse the following command

DESC TABLE_NAME;

you will get query information

jarlh
  • 42,561
  • 8
  • 45
  • 63
0

In Oracle you'd query the system views user_tab_cols, all_tab_cols or dba_tab_cols:

select * from user_tab_cols where table_name = :table_name;
Thorsten Kettner
  • 89,309
  • 7
  • 49
  • 73
-1

If you are running in mysql prompt you can disperse the following command

describe tablename

For your example

mysql>describe User or desc User

You will be getting the required information