How to get field name types from sql database

To get the field names, you must use the command:

select column_name from information_schema.columns where table_name='person'; 

My question is, how can I get the field types in a similar list?

+3
source share
5 answers
SELECT
    column_name
    column_type # or data_type 
FROM information_schema.columns 
WHERE table_name = 'person'; 

Schema Information

+10
source
select column_name,
       column_type 
  from information_schema.columns 
 where table_name='person';
0
source
SELECT
    column_name,
    data_type
FROM information_schema.columns 
WHERE table_name='person';
0

column_name column_type : column_name,      COLUMN_TYPE from information_schema.columns   table_name = 'personal_info';

column_name:

column_name from information_schema.columns   table_name = 'personal_info';

column_type: column_type from information_schema.columns   table_name = 'personal_info';

0
source

al shema

SELECT table_name, column_name, column_type FROM information_schema.columns WHERE table_schema = 'shema name'

0
source

Source: https://habr.com/ru/post/1752299/


All Articles