Oracle – Table Structure

| |
SELECT atc.TABLE_NAME
	,atc.COLUMN_NAME
	,atc.DATA_TYPE
	,CASE DATA_TYPE
		WHEN 'VARCHAR2'
			THEN '(' || DATA_LENGTH || ')'
		WHEN 'NUMBER'
			THEN CASE
					WHEN DATA_PRECISION IS NOT NULL
						THEN '(' || DATA_PRECISION || CASE
								WHEN DATA_SCALE <> 0
									THEN ',' || DATA_SCALE
								END
					END || CASE
					WHEN DATA_PRECISION IS NOT NULL
						THEN ')'
					END
		END DATA_LENGTH
FROM all_tab_columns atc
WHERE atc.TABLE_NAME = '<Table Name>';
Originally Posted on November 14, 2013
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.