Module 3: DB2 Objects
Alias
An alias is a locally defined alternate name for a table or view. It gives location independence - programs can use the alias while the real table lives anywhere, even on a remote DB2 system.
What is an alias
- An alias is an alternate name for a table or view.
- It gives DB2 location independence - the alias can point to a table on a remote system using a three-part name.
- Unlike a synonym, an alias can be used by users other than its creator.
- When a table is dropped, its synonyms are dropped but its aliases are retained.
- Aliases are created with CREATE ALIAS and removed with DROP ALIAS.
CREATE ALIAS - example
- An alias CUST_ALIAS for the CUSTOMER table:-
CREATE ALIAS MM01.CUST_ALIAS FOR MM01.CUSTOMER;
- Programs can now code SELECT ... FROM MM01.CUST_ALIAS instead of the real table name.
- To point at a remote table, use a three-part name:-
CREATE ALIAS MM01.REMOTE_CUST FOR REMOTEDB.MM01.CUSTOMER;
