473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Getting table attributes

C G
Dear All,

I'm trying to get a table containing all the user created tables, which
contains the column name and their types. Basically, I want to be able to
do "\d all_user_tables" - but I can't use the \d notation.

I tried to combine the pg_ tables, but I couldn't get what I wanted (due to
my lack of skill).

Any ideas?

Thanks

Colin

__________________________________________________ _______________
Find a cheaper internet access deal - choose one to suit you.
http://www.msn.co.uk/internetaccess
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 22 '05 #1
2 2716
this query will list every table (with its attributes) in the "public"
schema. You could alter the where clause to add more schemas (maybe
using IN):

SELECT
N.nspname,
C.relname,
A.attname,
pg_catalog.format_type(a.atttypid, a.atttypmod) AS typeName
FROM
pg_class C,
pg_namespace N,
pg_attribute A,
pg_type T
WHERE
(C.relkind='r') AND
(N.oid=C.relnamespace) AND
(A.attrelid=C.oid) AND
(A.atttypid=T.oid) AND
(A.attnum>0) AND
(NOT A.attisdropped) AND
(N.nspname ILIKE 'public')
ORDER BY
C.oid, A.attnum;
On Fri, 2004-02-06 at 13:53, C G wrote:
Dear All,

I'm trying to get a table containing all the user created tables, which
contains the column name and their types. Basically, I want to be able to
do "\d all_user_tables" - but I can't use the \d notation.

I tried to combine the pg_ tables, but I couldn't get what I wanted (due to
my lack of skill).

Any ideas?

Thanks

Colin

__________________________________________________ _______________
Find a cheaper internet access deal - choose one to suit you.
http://www.msn.co.uk/internetaccess


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQBAI86Q21dVnhLsBV0RAkx8AJ4634lTzmFhmV5/cJORUdwzJ6oLdwCgnKr0
O2a6dtNPupKq/VP9MX+YTOI=
=W0Sq
-----END PGP SIGNATURE-----

Nov 22 '05 #2
On Fri, Feb 06, 2004 at 04:53:47PM +0000, C G wrote:

I'm trying to get a table containing all the user created tables, which
contains the column name and their types. Basically, I want to be able to
do "\d all_user_tables" - but I can't use the \d notation.

I tried to combine the pg_ tables, but I couldn't get what I wanted (due to
my lack of skill).

Any ideas?


If you start psql with the -E flag then it'll show you the SQL query
it generates for the various \commands as you run them.

If you're using a recent version of postgres you can probably find the
data in a more version-independent way within information_schema, but I've
not played with that yet.

Cheers,
Steve

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jeff J. | last post by:
The basic concept is a music playlist that I'm trying to write as a table inside a div. I have Song and Playlist 'classes'. The Song class has a Write() method, as does the Playlist. The...
3
by: Mr. x | last post by:
Hello, I have simple table <table id = "mytable" ....> .... </table> I want to get the left position of the table. Everything I did getting wrong :
5
by: Sami | last post by:
Please bear with me, and if you answer this question, please do it step by step. I am new at Access, not at all sophisticated. I am using Office XP. This will need to be read in Access for...
6
by: melanieab | last post by:
Hi, Easy question. It seems to me that I'm following the examples correctly, but apparently I'm not. I'm trying to retrieve the data from a row called "row" and a column called "File". This is...
3
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are...
2
by: Muzzy | last post by:
Hi, I've used information on these newsgroups to build many pages. So I thought that now that I have my script working (something that I've been working on for about a week), I should post it so...
76
MMcCarthy
by: MMcCarthy | last post by:
Normalisation is the term used to describe how you break a file down into tables to create a database. There are 3 or 4 major steps involved known as 1NF (First Normal Form), 2NF (Second Normal...
2
by: Rahul B | last post by:
I am new at DB2 . so please guide I am trying to change the Datatype of a column in the table. CREATE TABLE testschema.player ( NAME VARCHAR(120) NOT NULL, country ...
8
by: Sundhas | last post by:
I made a Webservice Operation whose return type is STRING Following is the code @WebMethod(operationName = "authorize") public String authorize(@WebParam(name = "Username") String Username) { ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.