Home > Software design >  I am getting more than one result when checking column datatype postgresql
I am getting more than one result when checking column datatype postgresql

Time:11-05

Using solutions provided in this question Select datatype of the field in postgres i am able to query the datatype of a column from my table however i am getting two different results on same column

SELECT column_name, data_type FROM information_schema.columns WHERE 
table_name = 'mytable' AND column_name = 'timestamp';

RESULTS
-------
column_name|data_type               |
-----------|------------------------|
timestamp  |timestamp with time zone|
timestamp  |character varying       |

How do i know for sure which is the correct datatype for that column. is it a char... or time... datatype.

CodePudding user response:

It was maybe you had two tables with the same name in two different schemas.

Please change your query like that and add table_schema:

SELECT table_schema, column_name, data_type FROM information_schema.columns WHERE 
table_name = 'mytable' AND column_name = 'timestamp';
  • Related