Thread: creating a view that shows relation name -> OID
This works: select pg_class.oid, relname from pg_class where relowner=27; but this: CREATE VIEW VW_FOO AS select pg_class.oid, relname from pg_class where relowner=27; fails with: Attribute 'oid' has a name conflict Name matches an existing system attribute How come? TIA Kevin
The view is trying to make a column called oid which will already exist. Change your create to: CREATE VIEW VW_FOO AS select pg_class.oid as v_oid, relname from pg_class where relowner=27; -- Bill On Tue, Mar 13, 2001 at 09:39:23AM -0800, Kevin T. Manley wrote: > This works: > > select pg_class.oid, relname from pg_class where relowner=27; > > but this: > > CREATE VIEW VW_FOO AS select pg_class.oid, relname from pg_class where > relowner=27; > > fails with: > > Attribute 'oid' has a name conflict > Name matches an existing system attribute > > How come? > > TIA > Kevin > > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) -- _____ / ___/___ | Bill Huff / bhuff@colltech.com / /__ __/ | Voice: (512) 263-0770 x 262 / /__/ / | Fax: (512) 263-8921 \___/ /ollective | Pager: 1-800-946-4646 # 1406217 \/echnologies |------[ http://www.colltech.com ] ------
"Kevin T. Manley" <kmanley@qwest.net> writes: > CREATE VIEW VW_FOO AS select pg_class.oid, relname from pg_class where > relowner=27; > fails with: > Attribute 'oid' has a name conflict > Name matches an existing system attribute If you tried to create a table with a user column named 'oid' (or xmin or any of the other system attribute names), you'd get the same error. Views don't really have an oid column, but the system attribute names are reserved anyway. I'd recommend changing the name of the view's column, eg SELECT pg_class.oid AS reloid, ... regards, tom lane