Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm looking at a code base that I have inherited. I'm new to Postgres (but have an Oracle background), and I think this in one of the queries is an example of an enum. Can someone confirm if I'm correct in this thinking, and if not then what this is, and how I find out more about it.

SELECT fp.id AS fund_part_id, fp.fund_id, fp.principle_amount, fp.detail
FROM finance.fund_part fp
WHERE fp.status = 'live'::finance.fund_part_status;

I can see if the pg_enum catalog (table) that there are a series of records that belong to one enumtypid oid. Some of the entries in the enumlabel name column are ['live', 'for sale', 'pre-agrement']

share|improve this question

2 Answers 2

Yes, it looks like finance.fund_part_status is an enum type.

Assuming you're using the psql command-line interpreter, try this command:

\dT+ finance.fund_part_status;
share|improve this answer

You can find out for sure with this query to the system catalog table pg_type:

SELECT typtype
FROM   pg_type
WHERE  oid = 'finance.fund_part_status'::regtype

I quote the manual about pg_type:

typtype is b for a base type, c for a composite type (e.g., a table's row type), d for a domain, e for an enum type, p for a pseudo-type, or r for a range type. See also typrelid and typbasetype.

Bold emphasis mine.
More about the cast to regtype in the chapter about object identifier types.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.