-1

I'm new to oracle and I am doing simple exercises to broaden my knowledge I think I did every step successfully besides one.

The question was:

Create a table called Bank, which include following fields: Bank_id which is a number and has length of 5 and is primary key bank_name which is a string with length of 5 and may not be empty and Bank_Address which is a string, has length of 20 and is unique Here's what I wrote

CREATE TABLE Bank
{
Bank_id number(5) primary key,
Bank_name varchar(5) NOT NULL,
 bank_address varchar(20)

}

My question is following How do I declare something as unique? and is rest of my assignment correct? I'm asking you this because I am not able to view correct answer for few days and I'm anxious to know if I did this correctly, excuse my English and thanks.

1 Answers1

1

You need to add a unique constraint for the field bank_address to be unique like

CONSTRAINT bnk_addr UNIQUE (bank_address)

With that your CREATE TABLE statement should look like

CREATE TABLE Bank
(
Bank_id number(5) primary key,
Bank_name varchar(5) NOT NULL,
bank_address varchar(20),
CONSTRAINT bnk_addr UNIQUE (bank_address)
);
Rahul
  • 76,197
  • 13
  • 71
  • 125