Why do people abbreviate aliases?

This is strictly a philosophical question. But it’s one that I have had ever since I started using sql decades ago.

I often see queries like:

SELECT u.name, p.name FROM user AS u LEFT JOIN person AS p ON …

To me it would be just as easy to use

SELECT user.name,person.name FROM user AS user LEFT JOIN person AS person ON …

And so much easier to read especially when coming back to the query or reviewing someone else’s query.

Yet almost everyone seems to insist on using one of two character aliases. And okay, maybe it’s not so bad with only two tables but once you start joining more tables then it seems like it often becomes a big mess trying to remember the difference between ux and uy or whatever.

There has got to be some history behind this convention. Any ideas besides less typing?

and i’ll give a strictly philosophical answer

it is all about signal to noise and less about the amount of keystrokes (since experienced sql writers tend to use copy/paste a lot)

i assure you, when you run across a query that uses full length table name qualifiers on all columns, it’s a ~b1tch~ to read it easily

of course, every technique can be misused, and there is a special section of hell reserved for sql writers who use table aliases a, b, c, …

by the way, it hurts the signal to noise ratio when you assign an alias to a table which is the same as the table name…

FROM user AS user LEFT JOIN person AS person ON …

as for being “so much easier to read especially when coming back to the query or reviewing someone else’s query” i would invite you to learn about the benefits of indents and line breaks

:slight_smile: