to count no of columns in a table

Started by AKHILESH GUPTAabout 20 years ago4 messagesgeneral
Jump to latest
#1AKHILESH GUPTA
akhilesh.davim@gmail.com

hi all,
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
plz help me it's urgent
THANKS IN ADVANCE............!

--
Thanks & Regards,
Akhilesh
DAV Institute of Management
Faridabad(Haryana)-INDIA

"FAILURES CAN BE FORGIVEN BUT AIMING LOW IS A CRIME"

#2Juris
bubliks@gmail.com
In reply to: AKHILESH GUPTA (#1)
Re: to count no of columns in a table

Create view/storedproc on pg_class & pg_attribute tables

2006/2/16, AKHILESH GUPTA <akhilesh.davim@gmail.com>:

Show quoted text

hi all,
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
plz help me it's urgent
THANKS IN ADVANCE............!

--
Thanks & Regards,
Akhilesh
DAV Institute of Management
Faridabad(Haryana)-INDIA

"FAILURES CAN BE FORGIVEN BUT AIMING LOW IS A CRIME"

#3A. Kretschmer
andreas.kretschmer@schollglas.com
In reply to: AKHILESH GUPTA (#1)
Re: to count no of columns in a table

am 16.02.2006, um 14:43:43 +0530 mailte AKHILESH GUPTA folgendes:

hi all,
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.

select count(column_name) from information_schema.columns where table_name='foo';

HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47215, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===

#4Ragnar
gnari@hive.is
In reply to: AKHILESH GUPTA (#1)
Re: [SQL] to count no of columns in a table

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