PostgreSQL equivalent for mysql_field_flags

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Paw
Forum Newbie
Posts: 20
Joined: Tue Jul 17, 2007 10:27 am

PostgreSQL equivalent for mysql_field_flags

Post by Paw »

Hey folks,

I'm looking for a solution to retrieving field flag information for result set fields using PostgreSQL.
There is obviously no function available, which does the same like mysql_field_flags. So I guess a SQL query will be required.

However, I see a problem there, if the SQL query, which produced the previously mentioned result set, contained some attribute renaming:

Code: Select all

SELECT name as X FROM users
so there won't be a way to retrieve the desired field flags in every case, on the workaround route; or am I wrong?
I mainly need to know about a result set field, whether it is a primary key or not.

I hope someone knows a solution for this problem :-/


Thanks in advance!
Paw
Forum Newbie
Posts: 20
Joined: Tue Jul 17, 2007 10:27 am

Post by Paw »

Well, I couldn't solve my problem, but at least find information about PostgreSQL's storage locations for table constraints.
So I could create following query:

Code: Select all

SELECT column_name, constraint_type FROM information_schema.constraint_column_usage NATURAL JOIN information_schema.table_constraints WHERE table_name='table'
This returns the constraint type for each column, if a constraint is defined.
Post Reply