please confirm casting is required for precision mismatch of same data type?
For example: I have table EMP having column Designation char(20) and I have another table EMPLOYEE having column Designation char(30). I would create view by UNION these two tables EMP and EMPLOYEE but precision mismatch for column Designation. Please let me know casting is required here.
Thanks in advance!
The first select determines the datatype of the result, when you SELECT EMP.Designation UNION SELECT EMPLOYEE.Designation the result will be CHAR(20) and data in EMPLOYEE.Designation will be silently truncated to 20 chars.
When you do the union vice versa, it will be ok.
But i would recommend a CAST instead of relying on a specific order :-)