Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136

    Unanswered: Creating column or type with specific data

    Hello!

    How can i create type or column containing specific data, e.g.:

    create table dress(name .., size .., color ..);


    column or type: size
    with data: S | M | L

    _______
    column or type: color
    with data: blue | red | yellow

    Thanks for help!
    Last edited by julla27; 03-18-04 at 10:36.
    Regards,
    Julia

  2. #2
    Join Date
    Apr 2003
    Location
    Greenville, SC (USA)
    Posts
    1,155
    Ex:

    CREATE TYPE foo_t AS OBJECT (a1 NUMBER, a2 NUMBER);
    CREATE TABLE foo_tab (b1 NUMBER, b2 foo_t);
    INSERT INTO foo_tab VALUES (1, foo_t(2,3));


    HTH
    Gregg

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Creating column or type with specific data

    create table dress
    (name ..
    , size varchar2(1) check (size in ('S','M','L'))
    , color varchar2(10) check (color in ('blue','red','yellow'))
    );

    If you needed the flexibility to easily define new colors then:

    create table color
    ( color_name varchar2(10) primary key );

    create table dress
    (name ..
    , size varchar2(1) check (size in ('S','M','L'))
    , color_name references color
    );

  4. #4
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136
    Thank You!

    But i meant i want to create column (or type??) with
    predefined data, e.g.

    if i create in the table "dress" column "Size"
    i can only insert the values "S", "M" or "L".
    ______________________________________
    create table dress(name .., size .., color ..);

    column or type: size
    with data: S | M | L
    __________________________

    How can i realize this?
    Regards,
    Julia

  5. #5
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136
    Ok, I see!

    Thank You!
    Regards,
    Julia

Posting Permissions

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