Is it possible to generate a .txt file with the DESCRIBE TABLE from a table in Postgres by PHP? I need to download a .txt file with the description of the fields (name, type, character size) of the table where the query is being made.
Is it possible to generate a .txt file with the DESCRIBE TABLE from a table in Postgres by PHP? I need to download a .txt file with the description of the fields (name, type, character size) of the table where the query is being made.
You can first make the select in INFORMATION_SCHEMA, and then use Copy. I do not know if the text formatting suits you, but it's a starting point.
Example:
COPY (select column_name, data_type, character_maximum_length
from INFORMATION_SCHEMA.COLUMNS where table_name = 'nome_da_tabela') TO 'd:\nome_da_tabela.txt'