Can I get data types of each column I selected instead of the values, using a select statement?
FOR EXAMPLE:
SELECT a.name, a.surname, b.ordernum FROM customer a JOIN orders b ON a.id = b.id
and result should be like this
name | NVARCHAR(100) surname | NVARCHAR(100) ordernum| INTEGER
or it can be in row like this, it isn't important:
name | surname | ordernum NVARCHAR(100) | NVARCHAR(100) | INTEGER
Thanks
You can get the MySQL table columns data type with the help of “information_schema. columns”. SELECT DATA_TYPE from INFORMATION_SCHEMA. COLUMNS where table_schema = 'yourDatabaseName' and table_name = 'yourTableName'.
You can find details about the columns in your user's tables by querying user_tab_columns.
If the variable doesn't exist you'll get a NO_DATA_FOUND , and if there are two variables with the same name in the object you'll get ORA-01422: exact fetch returns more than requested number of rows .
I found a not-very-intuitive way to do this by using DUMP()
SELECT DUMP(A.NAME), DUMP(A.surname), DUMP(B.ordernum) FROM customer A JOIN orders B ON A.id = B.id
It will return something like:
'Typ=1 Len=2: 0,48'
for each column.
Type=1
means VARCHAR2/NVARCHAR2
Type=2
means NUMBER/FLOAT
Type=12
means DATE
, etc.
You can refer to this oracle doc for information Datatype Code
or this for a simple mapping Oracle Type Code Mappings
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With