Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces Pgadmin Support

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 07:37 PM
novnov
 
Posts: n/a
Default Does pgAdmin have to double-quote table and field names?


As far as I can tell pgsql itself does not require table and field names to
be wrapped in double quotes, but pgAdmin does that by default (at least on
windows). What's the rationale? I've not found a way to turn this off in
pgAdmin, is there a way, is it safe to do this?

It's a very nice package, btw, thanks to all of the contributors.
--
View this message in context: http://www.nabble.com/Does-pgAdmin-h....html#a7177095
Sent from the PostgreSQL - pgadmin support mailing list archive at Nabble.com.


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 07:37 PM
Dave Page
 
Posts: n/a
Default Re: Does pgAdmin have to double-quote table and

novnov wrote:
> As far as I can tell pgsql itself does not require table and field names to
> be wrapped in double quotes, but pgAdmin does that by default (at least on
> windows).


PostgreSQL does require you to use double quotes in some circumstances
(for example, if you use upper case letters). pgAdmin automatically
quotes identifiers if you use a name that requires them.

> What's the rationale? I've not found a way to turn this off in
> pgAdmin, is there a way, is it safe to do this?


No, you cannot turn it off, and yes, it is safe as long as you remember
to quote things appropriately outside of pgAdmin. See
http://www.postgresql.org/docs/8.1/s...AX-IDENTIFIERS
for more info.

> It's a very nice package, btw, thanks to all of the contributors.


You're welcome.

Regards, Dave

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 07:37 PM
novnov
 
Posts: n/a
Default Re: Does pgAdmin have to double-quote table and


I see, so to make it explicit, if I'd named my table item not Item, and the
column itemname not ItemName, pgAdmin (and pgsql) wouldn't need to double
quote. Not my preference but I'll live.

Thanks


Dave Page-3 wrote:
>
> novnov wrote:
>> As far as I can tell pgsql itself does not require table and field names
>> to
>> be wrapped in double quotes, but pgAdmin does that by default (at least
>> on
>> windows).

>
> PostgreSQL does require you to use double quotes in some circumstances
> (for example, if you use upper case letters). pgAdmin automatically
> quotes identifiers if you use a name that requires them.
>
> > What's the rationale? I've not found a way to turn this off in
>> pgAdmin, is there a way, is it safe to do this?

>
> No, you cannot turn it off, and yes, it is safe as long as you remember
> to quote things appropriately outside of pgAdmin. See
> http://www.postgresql.org/docs/8.1/s...AX-IDENTIFIERS
> for more info.
>
>> It's a very nice package, btw, thanks to all of the contributors.

>
> You're welcome.
>
> Regards, Dave
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
>


--
View this message in context: http://www.nabble.com/Does-pgAdmin-h....html#a7177919
Sent from the PostgreSQL - pgadmin support mailing list archive at Nabble.com.


---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 07:37 PM
novnov
 
Posts: n/a
Default Re: Does pgAdmin have to double-quote table and


I am having a discussion re pgsql double quoting or not in the General
mailing list, it's buried in the thread titled "Simple stored procedure
examples?" As far as I understand things, pgsql ignores case, unless I
explicitly use surround table and field names etc with double quotes. If I
use the double quotes then pgsql requires me to use referenece those objects
using double quotes and the exact case that I did originally. I'm not even
sure that I'm correct about all of that, but if I am, it seems that pgAdmin
is adding an uneccessary layer by automaticallly double quoting table and
field names that are not all lowercase.

This is important to me because I want to use namestyles like Item and
ItemName, and I don't want to have to double quote every table and field
reference. It seems that pgsql itself is fine with my preferred style but
that pgAdmin is effectively preventing it? I like pgAdmin otherwise so I'd
prefer not to have to hunt down a different editor.



Dave Page-3 wrote:
>
> novnov wrote:
>> As far as I can tell pgsql itself does not require table and field names
>> to
>> be wrapped in double quotes, but pgAdmin does that by default (at least
>> on
>> windows).

>
> PostgreSQL does require you to use double quotes in some circumstances
> (for example, if you use upper case letters). pgAdmin automatically
> quotes identifiers if you use a name that requires them.
>
> > What's the rationale? I've not found a way to turn this off in
>> pgAdmin, is there a way, is it safe to do this?

>
> No, you cannot turn it off, and yes, it is safe as long as you remember
> to quote things appropriately outside of pgAdmin. See
> http://www.postgresql.org/docs/8.1/s...AX-IDENTIFIERS
> for more info.
>
>> It's a very nice package, btw, thanks to all of the contributors.

>
> You're welcome.
>
> Regards, Dave
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
>


--
View this message in context: http://www.nabble.com/Does-pgAdmin-h....html#a7188642
Sent from the PostgreSQL - pgadmin support mailing list archive at Nabble.com.


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-17-2008, 07:37 PM
Dave Page
 
Posts: n/a
Default Re: Does pgAdmin have to double-quote table and

novnov wrote:
> I am having a discussion re pgsql double quoting or not in the General
> mailing list, it's buried in the thread titled "Simple stored procedure
> examples?" As far as I understand things, pgsql ignores case, unless I
> explicitly use surround table and field names etc with double quotes. If I
> use the double quotes then pgsql requires me to use referenece those objects
> using double quotes and the exact case that I did originally. I'm not even
> sure that I'm correct about all of that, but if I am, it seems that pgAdmin
> is adding an uneccessary layer by automaticallly double quoting table and
> field names that are not all lowercase.


pgAdmin is a GUI app that is designed to shield users from
implementation details wherever possible. When you create a table, you
don't need to know the SQL syntax, so why should you know about quoting
issues?

> This is important to me because I want to use namestyles like Item and
> ItemName, and I don't want to have to double quote every table and field
> reference. It seems that pgsql itself is fine with my preferred style but
> that pgAdmin is effectively preventing it? I like pgAdmin otherwise so I'd
> prefer not to have to hunt down a different editor.


in psql you're not using your preferred naming style as PostgreSQL will
be downcasing the names for you unless you quote them. The queries may
work, but as soon as you attach an ODBC app, .NET app, Java app or
whatever, it will see all the names in lowercase.

Regards, Dave.

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-17-2008, 07:37 PM
novnov
 
Posts: n/a
Default Re: Does pgAdmin have to double-quote table and


Hi Dave and thanks for responding.

I have to worry about the SQL syntax because practically the first thing I
did after using pgAdmin to create the tables was to try to write a stored
proceedure with pgAdmin against the table. The stored proceedure wouldn't
work until I manually added the double quotes. Naturally as a novice I
didn't know about needing the double quotes. pgAdmin automatically adds the
double quotes at table creation time but does not for the stored
proceedures, and the error returned (ERROR relation "item" does not exist)
doesn't exactly give one a clue that the issue is missing double quotes. The
pgAdmin GUI I'm sure it not supposed to provide complete isolation from SQL
syntax...it was an issue for me right away.

The second part of what you wrote adds to my confusion. You're saying that
ultimately pgsql is strict about lowercase on everything unless double
quoted, tho internally it is looser than that. Essentially then pgAdmin is
automatically adding the double quotes to names like Item as a safety
measure, knowing that eventually the double quotes will likely be important?

It's confusing because in the other mailing list I seem to have been told
simply that the issue I ran into was due to a habit of pgAdmin. In a way you
confirm, but clarify that pdAdmin is doing it for 'my own good'?




Dave Page-3 wrote:
>
> novnov wrote:
>> I am having a discussion re pgsql double quoting or not in the General
>> mailing list, it's buried in the thread titled "Simple stored procedure
>> examples?" As far as I understand things, pgsql ignores case, unless I
>> explicitly use surround table and field names etc with double quotes. If
>> I
>> use the double quotes then pgsql requires me to use referenece those
>> objects
>> using double quotes and the exact case that I did originally. I'm not
>> even
>> sure that I'm correct about all of that, but if I am, it seems that
>> pgAdmin
>> is adding an uneccessary layer by automaticallly double quoting table and
>> field names that are not all lowercase.

>
> pgAdmin is a GUI app that is designed to shield users from
> implementation details wherever possible. When you create a table, you
> don't need to know the SQL syntax, so why should you know about quoting
> issues?
>
>> This is important to me because I want to use namestyles like Item and
>> ItemName, and I don't want to have to double quote every table and field
>> reference. It seems that pgsql itself is fine with my preferred style but
>> that pgAdmin is effectively preventing it? I like pgAdmin otherwise so
>> I'd
>> prefer not to have to hunt down a different editor.

>
> in psql you're not using your preferred naming style as PostgreSQL will
> be downcasing the names for you unless you quote them. The queries may
> work, but as soon as you attach an ODBC app, .NET app, Java app or
> whatever, it will see all the names in lowercase.
>
> Regards, Dave.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
>


--
View this message in context: http://www.nabble.com/Does-pgAdmin-h....html#a7189127
Sent from the PostgreSQL - pgadmin support mailing list archive at Nabble.com.


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-17-2008, 07:37 PM
Dave Page
 
Posts: n/a
Default Re: Does pgAdmin have to double-quote table and

novnov wrote:
> Hi Dave and thanks for responding.
>
> I have to worry about the SQL syntax because practically the first thing I
> did after using pgAdmin to create the tables was to try to write a stored
> proceedure with pgAdmin against the table. The stored proceedure wouldn't
> work until I manually added the double quotes. Naturally as a novice I
> didn't know about needing the double quotes. pgAdmin automatically adds the
> double quotes at table creation time but does not for the stored
> proceedures, and the error returned (ERROR relation "item" does not exist)
> doesn't exactly give one a clue that the issue is missing double quotes. The
> pgAdmin GUI I'm sure it not supposed to provide complete isolation from SQL
> syntax...it was an issue for me right away.
>
> The second part of what you wrote adds to my confusion. You're saying that
> ultimately pgsql is strict about lowercase on everything unless double
> quoted, tho internally it is looser than that. Essentially then pgAdmin is
> automatically adding the double quotes to names like Item as a safety
> measure, knowing that eventually the double quotes will likely be important?


Anywhere you type raw SQL in pgAdmin, you need to quote manually. In
other words, if you manually type SQL into the Query Tool, or in a
function body. pgAdmin doesn't try to second guess what you've typed in
these cases - to to so would likely cause more problems.

In the GUI elements of pgAdmin, quoting is always added if you use an
identifier that requires it. In these cases it knows exasctly what you
are typing because you've typed it into the 'name' textbox for example.

psql is essentially the same as the pgAdmin query tool in that you must
do everything yourself.

> It's confusing because in the other mailing list I seem to have been told
> simply that the issue I ran into was due to a habit of pgAdmin. In a way you
> confirm, but clarify that pdAdmin is doing it for 'my own good'?


The point of a graphical interface is to simplify complex tasks for you.
In this case that means giving you a set of textboxes, comboboxes and
other widgets with which you specify the object you want to create. It
shields you from the details of how that object is created, because in
the vast majority of cases people don't care (in pgAdmin's case you
actually can see the raw SQL if desired by looking at the SQL tab on the
properties dialogues).

Regards, Dave.

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-17-2008, 07:37 PM
novnov
 
Posts: n/a
Default Re: Does pgAdmin have to double-quote table and


Thanks again.

Is there anything like SOP for pgsql devs then? Do most stick to lowercase
everywhere, and skip the issues, or do they keep the namestyles like
"ItemName" and just accomodate the need to double quote when it arises? I am
sure good devs could go either way, but curious if you or other have any
impressions re common practice. I'd guess most decide to use the "ItemName"
style, since double quoting would only be an issue under some circumstances
(like writing sprocs), and double quotes aren't a heavy burden anyways.



Dave Page-3 wrote:
>
> novnov wrote:
>> Hi Dave and thanks for responding.
>>
>> I have to worry about the SQL syntax because practically the first thing
>> I
>> did after using pgAdmin to create the tables was to try to write a stored
>> proceedure with pgAdmin against the table. The stored proceedure wouldn't
>> work until I manually added the double quotes. Naturally as a novice I
>> didn't know about needing the double quotes. pgAdmin automatically adds
>> the
>> double quotes at table creation time but does not for the stored
>> proceedures, and the error returned (ERROR relation "item" does not
>> exist)
>> doesn't exactly give one a clue that the issue is missing double quotes.
>> The
>> pgAdmin GUI I'm sure it not supposed to provide complete isolation from
>> SQL
>> syntax...it was an issue for me right away.
>>
>> The second part of what you wrote adds to my confusion. You're saying
>> that
>> ultimately pgsql is strict about lowercase on everything unless double
>> quoted, tho internally it is looser than that. Essentially then pgAdmin
>> is
>> automatically adding the double quotes to names like Item as a safety
>> measure, knowing that eventually the double quotes will likely be
>> important?

>
> Anywhere you type raw SQL in pgAdmin, you need to quote manually. In
> other words, if you manually type SQL into the Query Tool, or in a
> function body. pgAdmin doesn't try to second guess what you've typed in
> these cases - to to so would likely cause more problems.
>
> In the GUI elements of pgAdmin, quoting is always added if you use an
> identifier that requires it. In these cases it knows exasctly what you
> are typing because you've typed it into the 'name' textbox for example.
>
> psql is essentially the same as the pgAdmin query tool in that you must
> do everything yourself.
>
>> It's confusing because in the other mailing list I seem to have been told
>> simply that the issue I ran into was due to a habit of pgAdmin. In a way
>> you
>> confirm, but clarify that pdAdmin is doing it for 'my own good'?

>
> The point of a graphical interface is to simplify complex tasks for you.
> In this case that means giving you a set of textboxes, comboboxes and
> other widgets with which you specify the object you want to create. It
> shields you from the details of how that object is created, because in
> the vast majority of cases people don't care (in pgAdmin's case you
> actually can see the raw SQL if desired by looking at the SQL tab on the
> properties dialogues).
>
> Regards, Dave.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>
>


--
View this message in context: http://www.nabble.com/Does-pgAdmin-h....html#a7191015
Sent from the PostgreSQL - pgadmin support mailing list archive at Nabble.com.


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-17-2008, 07:37 PM
Erwin Brandstetter
 
Posts: n/a
Default Re: Does pgAdmin have to double-quote table and

novnov wrote:
> Is there anything like SOP for pgsql devs then? Do most stick to lowercase
> everywhere, and skip the issues, or do they keep the namestyles like
> "ItemName" and just accomodate the need to double quote when it arises? I am
> sure good devs could go either way, but curious if you or other have any
> impressions re common practice. I'd guess most decide to use the "ItemName"
> style, since double quoting would only be an issue under some circumstances
> (like writing sprocs), and double quotes aren't a heavy burden anyways.
>



I would generally stick to lower case names. Just like I would generally
avoid non-ASCII characters in names. I certainly do, I think most do.
Makes your life easier.


Regards
Erwin

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-17-2008, 07:38 PM
novnov
 
Posts: n/a
Default Re: Does pgAdmin have to double-quote (now


I will be asking this on the pgsql general list too but if lowercase is best,
I'll have to change some habits I've developed over the years, want to glean
whatever collective wisdom I can here from experienced pgsql devs.

I've been using namestyles with mixed case like OrgID. That is much more
readable than orgid. I know many would use org_id. That change I can live
with.

But another issue is the way that I've been naming foreign key references. I
tend to prefix field names with a table based acryonym. So names like
OrgName, OrgCity. Foreign key fields incorporate the ref'd pk. So, if I have
a table tblEmployee, fk to the org table would be like EmpOrgID. I know many
would simply use OrgID as the fk in tblEmployee, but I have liked
compounding the names because is results in completly unambiguous field
names throughout the db. If I'm giving up the mixed case naming, I could use
emp_fname, emp_lname, emp_org_id, but I'm not sure if that's best.

I am very curious to hear the various conventions folks here have arrived
at. I don't expect there to be consensus, but the various rationales might
help me arrive at an approach that works well for me.



brsaweda wrote:
>
> novnov wrote:
>> Is there anything like SOP for pgsql devs then? Do most stick to
>> lowercase
>> everywhere, and skip the issues, or do they keep the namestyles like
>> "ItemName" and just accomodate the need to double quote when it arises? I
>> am
>> sure good devs could go either way, but curious if you or other have any
>> impressions re common practice. I'd guess most decide to use the
>> "ItemName"
>> style, since double quoting would only be an issue under some
>> circumstances
>> (like writing sprocs), and double quotes aren't a heavy burden anyways.
>>

>
>
> I would generally stick to lower case names. Just like I would generally
> avoid non-ASCII characters in names. I certainly do, I think most do.
> Makes your life easier.
>
>
> Regards
> Erwin
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
>


--
View this message in context: http://www.nabble.com/Does-pgAdmin-h....html#a7243176
Sent from the PostgreSQL - pgadmin support mailing list archive at Nabble.com.


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:12 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426