Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2006
    Posts
    2

    Unanswered: Table of user defined types

    Hi!

    I have a question about creating a user defined type: I'd like to create a table of employee objects which include objects of the type employee_t. I used this structure before in Oracle 9i and would like to know how it can be done with MS SQL Server 2000 or 2005, preferably with Enteprise Manager/Management Studio. Below is an example.

    CREATE TYPE employee_t AS OBJECT (
    name VARCHAR(10)
    jobDesc VARCHAR(15)
    ...
    )

    CREATE TABLE Employee of employee_t

    Regards,

    Timo

  2. #2
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    Have you considered look up "user-defined data types" in Books Online?

    -- This is all just a Figment of my Imagination --

  3. #3
    Join Date
    Apr 2006
    Posts
    2

    Yes

    Yes I did, and the only helpful issue I could find there was about user defined data types which simply means that you can create some UDDT like:

    ...
    telephone_nr VARCHAR(15)
    ...

    This is a simple definition which assigns one data type to one column. I was looking for the creation of types with multiple attributes and nested tables within them.

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    No. SQL Server, like all the big database servers, is not "object-oriented". There have been attempts to create object-oriented relational databases, but they have not been commercially succesful. And no, I don't consider Oracle's implementation to be object-oriented either. Why create an "Employee" datatype for reuse, when Employee data should be stored in a single table anyway?
    Regardless, I would steer clear of User-Defined datatypes. If you look into the details of how they work, you will find that they really do not confer any advantages. Modifications to the datatype are not "inherited" by any instances of the datatype, and for scripting purposes the user-defined datatype is converted back to its underlying datatype.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •