Results 1 to 5 of 5

Thread: plz help newbie

  1. #1
    Join Date
    Sep 2003
    Posts
    3

    Unanswered: plz help newbie

    Hi all,

    I've just started using Oracle 8 for my uni course and I'm currently stuck on a problem which should be very easy to solve but I do not know how.

    The problem is I have to create a table where one of the attributes will only allow the user to enter a pre-defined data. E.g. for the Payment_Type in my Payment table, the user is only allowed to enter either cash, credit or direct credit, how do I enforce this?

    Do I have to specify something in the create statements? Plz help.

    Thank u.

  2. #2
    Join Date
    Aug 2003
    Posts
    41
    Hi,

    You can use check constraints on your table to do exactly that. Refer to Oracle documentation for the concepts and syntax.

    -Sunil

  3. #3
    Join Date
    Apr 2003
    Location
    Greenville, SC (USA)
    Posts
    1,155
    alter table SALES_REP add constraint CHK0003 check (PAY_METHOD = 'P' Or PAY_METHOD = 'A' Or PAY_METHOD = 'N');

    Adds a check constraint to the table Sales_Rep. It only allows a
    'P','A',OR 'N' to be inserted into the column Pay_Method

    Check Constraints ...

    hth
    Gregg

  4. #4
    Join Date
    Sep 2003
    Posts
    3
    cool, it worked. Thanks alot for the help!

  5. #5
    Join Date
    Sep 2003
    Location
    Atlanta
    Posts
    2
    Do we get brownie points for doing other peoples homework here? LOL

Posting Permissions

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