Amoora Amassi
Amoora Amassi

Reputation: 9

missing right parenthesis

I create two table int sql but the error missing right parenthesis appearing why?

create table  department(deptno number primary key,
                         deptname varchar(30) not null);

The error occur when I create this table

create table employee(eno number not null primary key,
                      fname varchar(30) not null,
                      lname varchar(30) not null,
                      job varchar(30) not null,
                      age number,
                      salary number(7,2),
                      comm number,
                      deptno number foreign key  references department(deptno),
                      address varchar(30) default 'new york');

Upvotes: 0

Views: 176

Answers (2)

Dgeyzonne
Dgeyzonne

Reputation: 66

Or you can do this to keep control over the name of your contraints :

create table employee
(
    eno       number not null,
    fname     varchar(30) not null,
    lname     varchar(30) not null,
    job       varchar(30) not null,
    age       number,
    salary    number(7, 2),
    comm      number,
    deptno    number,
    address   varchar(30) default 'new york',
    constraint pk_emp primary key (eno),
    constraint fk_emp_dep foreign key (deptno) references department(deptno)
);

Upvotes: 1

Marco Baldelli
Marco Baldelli

Reputation: 3728

To create an inline foreign key constraint you need to remove the foreign key words:

create table employee
(
   eno       number not null primary key,
   fname     varchar(30) not null,
   lname     varchar(30) not null,
   job       varchar(30) not null,
   age       number,
   salary    number(7, 2),
   comm      number,
   deptno    number references department(deptno),
   address   varchar(30) default 'new york'
);

Upvotes: 3

Related Questions