How can I get the DDL of a column?

Tags:
DDL
Oracle
VARCHAR
How can I get the DDL of a column? Suppose I declared a column with varchar2(10). So I need to extract that length of varchar i.e 10.


Software/Hardware used:
using oracle 11g
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

You can query the ALL_TAB_COLUMNS dictionary view to get the length:

SELECT data_length
FROM all_tab_columns
WHERE owner = '<YOUR_SCHEMA>'
   AND table_name = '<YOUR_TABLE>'
   AND column_name = '<YOUR_COLUMN>'
   AND data_type = 'VARCHAR2'; 

-CarlosDL

—————–

To get the 1st 10 characters, you can use the SQL keyword  SUBSTR

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Subhendu Sen
    A little confusion about your query. Did you want to get actual length of value in column. Or tried to get column max length. Please back with more specifications.
    140,480 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: