Oracle get column data size Oracle get column data size oracle oracle

Oracle get column data size


Check out user_tab_columns.

select data_type, data_length   from user_tab_columns where table_name = 'PRODUCTS'   and column_name = 'LOCATION';


Do you need to find out the type and size of a column for the purpose of understanding the data, or are you writing a program that needs to know it at runtime?

If you only need to know it for your knowledge, typing desc tablename in SQLPlus will tell you about the columns in the table.

If you need to find out the type and size programmatically, what language are you using ... PL/SQL? Java?

Note that selecting from USER_TAB_COLUMNS will only list the columns in tables in your own schema. For other tables you'll need to look at ALL_TAB_COLUMNS (or DBA_TAB_COLUMNS, if the DBA has allowed you to access it). Note that your employer or client may disallow stored procedures or packages from being compiled against either.


SELECT CHAR_LENGTH FROM USER_TAB_COLUMNS WHERE TABLE_NAME = <TABLENAME> AND COLUMN_NAME = <COLUMNNAME>;