Except when it’s necessary (self reference, etc.), is there a drawback NOT to use SQL aliases?
I often see queries like :
SELECT c.name, p.phone, a.number, ct.fbAddress
FROM customer c
INNER JOIN Person p ON p.idCustomer = c.idCuster
INNER JOIN Address a ON .... etc
It annoys me. It’s not easily maintainable. Why not use the full names? Is there a problem with it?
And that’s just an example. I’ve seen queries with 10-15 tables in them with this kind of shortcuts. It’s not readable.
Edit:
I should have written “It’s not easily readable” instead of “maintainable”. It’s true that it’s easier to change the name of a table if you only have to change it in the “FROM” clause.
Oh and by the ways, I’ve seen these “one letter aliases” mostly from DBAs, so I though maybe there was some performance issue or something.
There are no (performance) downsides to not using aliases. But I think many would agree to the opposite of your preferences. Aliases make SQL more readable. What is more enjoyable to read to you?
or
I would choose the former 11 times out of 10. Not to mention, the time saved, and the less error prone you are without having to type many times the characters with no aliases makes it quite worth it as well.
I will hand it to you, the one letter aliases (i.e.
a,c,p) can be rough. But when you have a table calledCompanyBillExtensions, it is easier and just as intuitive to write/readcbeorBillExt.