October 2006
Intermediate to advanced
464 pages
16h 11m
English
A user-defined data type (UDT) provides a convenient way for you to guarantee consistent use of underlying native data types for columns known to have the same domain of possible values. For example, perhaps your database will store various phone numbers in many tables. Although no single, definitive way exists to store phone numbers, in this database consistency is important. You can create a phone_number UDT and use it consistently for any column in any table that keeps track of phone numbers to ensure that they all use the same data type. Here’s how to create this UDT:
CREATE TYPE phone_number FROM varchar(20) NOT NULL;
And here’s how to use the new UDT when you create a table:
CREATE TABLE customer ( cust_id smallint NOT ...
Read now
Unlock full access