Second Step at defining type SID in SQL
CREATE TYPE SID AS VARCHAR(5) ;
Explanation:
- TYPE SID announces that a type named SID is being defined to the system.
- AS VARCHAR(5) defines SID as a distinct type, whose values are represented by values of type VARCHAR(5). In this form of type definition the given representation must be a system- defined type.
Under this definition, SID('S1') is exactly equivalent to the same expression in Tutorial D, and the SQL expression CAST(s AS VARCHAR(5)), where s is a value of type SID, is equivalent to Tutorial D's THE_C(s). However, we have no way of further constraining the string values representing student identifiers; so SID('34x.1'), for example, also denotes a value of type SID, as does SID(' ').