If you're a .Net developer aliases should be very familiar to you.
if they're not here is a reminder:
using MyAlias = This.Is.My.Full.Namespace.MyClass;
MyAlias m = new MyAlias(); // MyAlias is of course of type MyClass
Well it seems SQL Server 2005 added a similar functionality to T-SQL. It's called Synonyms.
You can use them in all CRUD operations as well as in sub-selects and dynamic SQL
What's interesting is that synonyms are evaluated at run time and the binding between the synonym and an object is by name only.
This means that you can drop the object referenced by the synonym at any time, but you'll get an error only at run-time.
They are useful because they provide a level of abstraction in your app, since you can change the name or even a location of the object
referenced by the synonym.
And not to mention having less to type as seen in this example:
-- Create a synonym for the Product table in AdventureWorks.
CREATE SYNONYM MyProduct
-- Query the Product table by using the synonym.
SELECT ProductID, Name
WHERE ProductID < 5;
These database objects can be referenced by a synonym:
- SQL stored procedures, scalar, table-valued and inline-tabled-valued functions
- Local and global temporary tables
- Replication-filter and extended stored procedures
- CLR stored procedures, table-valued, scalar and aggregate functions
Don't know in how widespread use this will be but it's a nice feature that can come in handy.