When using Toad for Oracle the wonderful schema browser provides a lot of information. One piece of that info that I would like to have available via a query is the Data Type information for a given table.
That extra bit of info listed in the Data Type column (1 Byte), provided in the Schema Browser is what I am looking for. When using the table ALL_TAB_COLS it provides a lot of that same info开发者_Go百科 but not that additional info about the Data Type.
Is there any way to have a Select statement return that same information?
Thanks!
The DATA_LENGTH field in ALL_TAB_COLUMNS provides the the length of the column (in your case 1), while CHAR_USED flag differentiates between CHAR (C) and BYTE (B).
That would be the column ALL_TAB_COLUMNS.CHAR_USED
From the manual at:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_2094.htm#I1020277
B indicates that the column uses BYTE length semantics. C indicates that the column uses CHAR length semantics
SELECT
COLUMN_NAME,
DATA_TYPE,
DATA_LENGTH,
DATA_PRECISION,
DATA_SCALE
FROM ALL_TAB_COLS
Where TABLE_NAME = 'table_name';
If that doesn't work your table may be in capital letters so try this.
SELECT
COLUMN_NAME,
DATA_TYPE,
DATA_LENGTH,
DATA_PRECISION,
DATA_SCALE
FROM ALL_TAB_COLS
Where TABLE_NAME = upper('table_name');
I wanted to add some information because of title. This is the first thing that comes up when you search for toad check what kind of data type something is
.
Simply put the cursor on a function, table, or other object in the editor window and press the F4 key, and detail about the object appears.
https://www.oreilly.com/library/view/toad-for-oracle/9780134131900/ch03lev1sec3.html
精彩评论