PostgreSQL, Oracle, and MySQL use data dictionaries to obtain the table structure. The schema name and table name are required.
PostgreSQL:
Select a. attname, pg_catalog.format_type (A. atttypid, A. atttypmod) as data_type
From pg_catalog.pg_attribute,
(Select C. OID
From pg_catalog.pg_class C
Left join pg_catalog.pg_namespace n
On n. OID = C. relnamespace
Where (C. relname) = lower ('cxf ')
And (N. nspname) = lower ('public') B
Where a. attrelid = B. OID
And a. attnum> 0
And not a. attisdropped order by A. attnum
Attname | data_type
--------- + ------------------------
A | integer
B | character varying (100)
(2 rows)
MySQL:
Create Table dwarch. cxf (A int, B varchar (100 ));
Select column_name, Concat (data_type, case when upper (data_type) like '% char %' Then Concat (', character_maximum_length,') else ''end) as datatype
From information_schema.columns
Where upper (table_schema) = upper ('test ')
And upper (table_name) = upper ('cxf ')
+ ------------- + -------------- +
| Column_name | datatype |
+ ------------- + -------------- +
| A | int |
| B | varchar (100) |
+ ------------- + -------------- +
ORACLE:
Select column_name, data_type | case when data_type like '% char % 'then' (' | data_length | ') 'end as data_type
From all_tab_columns
Where owner = upper ('test ')
And table_name = upper ('cxf ')
Order by column_id;