Re: [SQL] to count no of columns in a table

From: Ragnar <gnari(at)hive(dot)is>
To: AKHILESH GUPTA <akhilesh(dot)davim(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] to count no of columns in a table
Date: 2006-02-16 09:40:36
Message-ID: 1140082836.32324.38.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

On fim, 2006-02-16 at 14:43 +0530, AKHILESH GUPTA wrote:
> i just want to know one thing that is there any function in PGSQL
> which gives me the total number of columns in a table.
> OR
> just like we are using count(*), it gives us total number or rows in a
> table, just like i want to know the total number of columns present in
> the table

this is the kind of thing the information_schema is for

select count(*) from information_schema.columns
where table_name='x';

gnari

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bart Golda 2006-02-16 09:56:30 Re: Connecting process to PostgreSQL works stunningly slow
Previous Message A. Kretschmer 2006-02-16 09:37:17 Re: to count no of columns in a table

Browse pgsql-sql by date

  From Date Subject
Next Message Antal Attila 2006-02-16 11:26:54 VIEWs and TEMP tables problem
Previous Message A. Kretschmer 2006-02-16 09:37:17 Re: to count no of columns in a table