Home

Tables should be aliased

Rule description

  • Tables should be aliased

 

Non-compliant Code Example

SELECT 
    NAME,
    ADDRESS,
    CREDIT_LIMIT       
FROM CUSTOMERS                  --Non compliant code (Tables are not aliased)
INNER JOIN VENDOR               --Non compliant code (Tables are not aliased)
	ON VENDOR.NAME IS NOT NULL AND VENDOR.NAME = CUSTOMERS.NAME;

Compliant Code Example

SELECT 
    cust.NAME,
    cust.ADDRESS,
    cust.CREDIT_LIMIT       
FROM CUSTOMERS cust                 --Compliant code (Aliased used for tables)
INNER JOIN VENDOR ven               --Compliant code (Aliased used for tables)
	ON ven.NAME IS NOT NULL AND ven.NAME = cust.NAME
Visual Expert 2020
 VEPLSQLRULE150