数据库新技术06要领.pptVIP

  • 3
  • 0
  • 约2.05万字
  • 约 93页
  • 2017-06-15 发布于北京
  • 举报
2 复杂对象 用复合数据类型构造复杂对象(抽象数据类型ADT) 定义一个组合数据类型。 CREATE TYPE 类型名 ( 属性名 数据类型 [, 属性名 数据 类型, ……]); 集合类型 用关键词 setof(T)说明,T是任意数据类型。 setof(T)是类型为T的值的集合数据类型。 引用类型 用关键词 ref(T),T可以是任意数据类型 2 复杂对象 例子:图书(书号、书名、作者、 出版社、出版日期) CREATE TYPE mystring varchar(40); CREATE TYPE mydate ( year integer, month integer, day integer); CREATE TYPE publisher_t (publi_ name cahr(20), address varchar(40), telephone intger); 2 复杂对象 CREATE TYPE book_t (bookno char(20), bookname varchar(40), author setof (mystring), publisher_ref ref (publisher_t), date mydate); CREATE TABLE publisher of type publisher_t; CREATE TABLE book of type book_t; 2 复杂对象 扩充的数据类型的使用方法 ①用户定义的函数能够使用组合、集合、引用等作为参数或返回值。 ②返回组合、集合、引用等类型的函数可以出现在SQL查询的from子句中。 ③用“级联点注”来引用组合、集合、引用等对象的属性。 Structured types can be declared and used in SQL create type Name as (firstname varchar(20), lastname varchar(20)) final create type Address as (street varchar(20), city varchar(20), zipcode varchar(20)) not final Final不能 and not final可以创建子类型 Structured types can be used to create tables with composite attributes create table customer ( name Name, address Address, dateOfBirth date) 用点 · Dot来引用 components: name.firstname User-defined row types create type CustomerType as ( name Name, address Address, dateOfBirth date) not final Can then create a table whose rows are a user-defined type create table customer of CustomerType Can add a method declaration with a structured type. method ageOnDate (onDate date) returns interval year Method body is given separately. create instance method ageOnDate (onDate date) returns interval year for CustomerType Begin return o

文档评论(0)

1亿VIP精品文档

相关文档