How do I get the types of columns for postgresql? I am trying to get the type of the column. For instance I have two columns for names and ids and they are text and integer respectively. I have 3 of them:

name    id
george  5
takashi 2
hans    8


Is that possible to get a result like that?

name id
text int
text int
text int


I have seen this code below and it did not work for me

select column_name,data_type 
from information_schema.columns 
where table_name = 'table_name';
Based on the query you already have,

SELECT (SELECT data_type
               FROM information_schema.columns
               WHERE table_schema = 'public'
                     AND table_name = 'table_name'
                     AND column_name = 'name') "name",
       (SELECT data_type
               FROM information_schema.columns
               WHERE table_schema = 'public'
                     AND table_name = 'table_name'
                     AND column_name = 'id') "id";


would produce the output you want (but only a single row, which is enough per your comment).

SQL Fiddle