MySQL

Page 307

290

OBJECT-ORIENTED FEATURES OF THE SQL: 1999 STANDARD

Creating Classes The complete syntax for declaring a class--for use either as a colu m n data type or a typed table--is as follows" CREATE TYPE [UNDER supectype_name] type name [ < e x t e c n a l Java type clause> ] [ AS c e p c e s e n t a t i o n ] [ [ NOT ] INSTANTIABLE ] [ NOT ] FTNAL [ cefecence-type-specificatlon ] [ <cefecence c a s t o p t l o n > ] [ cast option ] [ method s p e c i f i c a t i o n list ]

In its simplest form, the syntax requires the first, third, and fourth lines just shown. For example, a telephone number could be represented as: CREATE TYPE phone_number AS ( area code char ( 3 ) , exchange char ( 3 ) , s i t e number char ( 4 ) , e x t e n s i o n char ( 5 ) , number_type v a r c h a r ( 1 5 ) ) NOT FINAL; m

The NOT FINAL syntax is required as is. It means that subclasses can be derived from that class. The SQL:1999 standard does not provide for a FINALoption to prevent the derivation of subclasses. By default, a class is instantiable: Objects can be created from it. If you want a class to be abstract~to prevent objects from being created from i t ~ a d d the NOT INSTANTIABLE clause. When creating a class for a typed table, the syntax must indicate from where the value for the self-referencing column will come. If you want the DBMS to generate the value, add REF TS SYSTEM GENERATED


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.