0
create table patient (
    p_code number(5) primary key,
    p_name varchar2(50) not null,
    DOB date(15) not null,
    p_phone number(30)   default null,
    st varchar2(20) not null,
    city varchar2(15) not null,
    state varchar2(15)   default null,
    zip_code number(10) not null,
    w_code number(5) references ward (w_code)  
)

it gives me ORA-00907: missing right parenthesis

1
  • 1
    by default its null, you don't need to say default null. Commented Dec 27, 2014 at 13:48

1 Answer 1

1

In all databases, the default value for a column is NULL when you leave out not null. So, you can write:

create table patient (
    p_code number(5) not null primary key,
    p_name varchar2(50) not null,
    DOB date not null,
    p_phone number(30),
    st varchar2(20) not null,
    city varchar2(15) not null,
    state varchar2(15),
    zip_code number(10) not null,
    w_code number(5) references ward (w_code)  
)

As a note. Oracle also accepts null and default null for this purpose, so these are also acceptable:

    p_phone number(30) null,
    p_phone number(30) default null,

The problem with your code was the date(15). date doesn't take a length argument.

By the way, you should be storing phone numbers and zip codes using strings and not numbers. They can have leading zeros.

Sign up to request clarification or add additional context in comments.

Comments

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.