Thread: BUG #14200: Cannot create a table named 'user'
VGhlIGZvbGxvd2luZyBidWcgaGFzIGJlZW4gbG9nZ2VkIG9uIHRoZSB3ZWJz aXRlOgoKQnVnIHJlZmVyZW5jZTogICAgICAxNDIwMApMb2dnZWQgYnk6ICAg ICAgICAgIE1hdHRoZXcgRGkgUGFzcXVhbGUKRW1haWwgYWRkcmVzczogICAg ICBsaXZlbG92ZXByb3NwZXJAZ21haWwuY29tClBvc3RncmVTUUwgdmVyc2lv bjogOS41LjMKT3BlcmF0aW5nIHN5c3RlbTogICBPUyBYIDEwLjExLjUKRGVz Y3JpcHRpb246ICAgICAgICAKClByb2JsZW06DQpodHRwOi8vc3RhY2tvdmVy Zmxvdy5jb20vcS8yMjI1NjEyNA0KDQpXaHkgZG9lc24ndCB0aGUgdXNlciB0 YWJsZSBoYXZlIHRoZSBwZ18gcHJlZml4IG9yIHNvbWUgb3RoZXIgcHJlZml4 Pw0KDQpXaGF0IGlmIEkgd2FudCB0byBjcmVhdGUgYSB1c2VyIHRhYmxlIGZv ciBteSBhcHBsaWNhdGlvbj8gU2hvdWxkbid0IEkgYmUKYWJsZSB0byBjYWxs IHRoYXQgdGFibGUgdXNlcj8NCg0KV291bGQgdGhlIG9ubHkgcmVhc29uIHRv IHVzZSB0YWJsZSBuYW1lIHByZWZpeGVzIGJlIHRvIGF2b2lkIHRoaXMKY29u ZmxpY3Q/DQpodHRwOi8vc3RhY2tvdmVyZmxvdy5jb20vcXVlc3Rpb25zLzMy NDE2My9zaG91bGQtd2UtdXNlLXByZWZpeGVzLWluLW91ci1kYXRhYmFzZS10 YWJsZS1uYW1pbmctY29udmVudGlvbnMjY29tbWVudDYxNjI5NjM2XzMyNDE4 MwoK
On Saturday, June 18, 2016, <liveloveprosper@gmail.com> wrote: > The following bug has been logged on the website: > > Bug reference: 14200 > Logged by: Matthew Di Pasquale > Email address: liveloveprosper@gmail.com <javascript:;> > PostgreSQL version: 9.5.3 > Operating system: OS X 10.11.5 > Description: > > Problem: > http://stackoverflow.com/q/22256124 Not a bug. And it was asked and answered, correctly, two years ago. > Why doesn't the user table have the pg_ prefix or some other prefix? You should read that SO post again... It does. Check the docs for proof. Or just try <select * from user> in newly created database. Then try <select * from pg_user>. > What if I want to create a user table for my application? Shouldn't I be > able to call that table user? If you quote it you can. But as the SO answer advises just live with the fact it's not a recommended approach. > > Would the only reason to use table name prefixes be to avoid this > conflict? > > http://stackoverflow.com/questions/324163/should-we-use-prefixes-in-our-database-table-naming-conventions#comment61629636_324183 > > Don't know what you are asking for here... David J.
"David G. Johnston" <david.g.johnston@gmail.com> writes: > On Saturday, June 18, 2016, <liveloveprosper@gmail.com> wrote: >> What if I want to create a user table for my application? Shouldn't I be >> able to call that table user? > If you quote it you can. Worth noting here is that USER is a reserved word according to the SQL standard, as well as our documentation: https://www.postgresql.org/docs/9.5/static/sql-keywords-appendix.html You should not be surprised that you can't use it as a generic identifier without adding quotes. (The only reason it's reserved in Postgres is to implement the spec-defined meaning of the keyword. I can't imagine that we'd have chosen to reserve it without that requirement.) regards, tom lane