0

I am new to oracle and i'm trying to create a foreign key to another table

CREATE TYPE Salary_typ AS OBJECT (
    Sal_SlipId NUMBER (11),
    Sal_BankDetails VARCHAR (255),
    Sal_Salary NUMBER (11,2),
    Sal_Month VARCHAR (255),
    Sal_Employee REF Employee_typ
    )
    /

this is the type that i created

and this is the table

CREATE TABLE Salary OF Salary_typ (
    Primary Key (Sal_SlipId),
    Sal_Employee REFERENCES Employee 
    )
    /

I tried executing these but all i get is a garbage value for foreign key

1 Answer 1

1

If you are new to Oracle, don't try to create tables based on types - nobody does that!

Do this instead:

create table salary (
    Sal_SlipId NUMBER (11),
    Sal_BankDetails VARCHAR (255),
    Sal_Salary NUMBER (11,2),
    Sal_Month VARCHAR (255),
    Sal_Employee REFERENCES employees
);
Sign up to request clarification or add additional context in comments.

1 Comment

Is there a way to this with a type?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.