Created
September 17, 2009 13:43
-
-
Save faried/188494 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- find all psql tables owned by user 'pkf' that are of type date, timestamp, or timestamp with timezone | |
select c.relname, a.attname, format_type(a.atttypid, a.atttypmod) as coltype from pg_class c | |
join pg_attribute a on (c.oid = a.attrelid) | |
join pg_roles r on (c.relowner = r.oid) | |
where | |
c.relkind = 'r' and r.rolname = 'pkf' and | |
a.atttypid in (select oid from pg_type where typname in ('date', 'time', 'timestamp', 'timestamptz')) | |
order by c.relname, a.attname; | |
-- output is like | |
relname | attname | coltype | |
----------------------+------------------+----------------------------- | |
announcements | date | timestamp without time zone | |
announcements | posteddate | timestamp without time zone | |
barf | d | timestamp with time zone | |
billingexpire | expiredate | date | |
billinglog | logdate | date | |
billingpayments | bounced | date | |
billingpayments | cleared | date | |
billingpayments | payment | date | |
boardmeetings | date | timestamp without time zone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment