Abdul
Abdul

Reputation: 37

Error at line 1: ORA-00907: missing right parenthesis

I believe I have the right syntax for SQL plus command, I have tried different ways to do it but I am getting the same error message. I don't know why i am getting this "missing right parenthesis error" any help will be appreciated thank you in advance. here is my code:

create table PUBLISHERS (
NAME varchar2(50) primary key, 
address varchar2(50), phone integer(10) 
);

Upvotes: 2

Views: 5183

Answers (3)

sweeta
sweeta

Reputation: 1

create table doctor_details(doctor_id number(10),
username varchar2(30) not null,
password varchar2(30) not null,
name varchar2(30) not null,
father_name varchar2(30) not null,
gender varchar2(6) not null check(gender in('male','female)),
email varchar2(50) not null,
contact_no number(10) not null,
qualification varchar2(50) not null,
specialization varchar2(5) not null,
date_of_birth date not null,
date_of_joining date not null,
 primary key(doctor_id))

error is right parenthesis missing

Upvotes: 0

Dba
Dba

Reputation: 6649

INTEGER is not a Oracle Built-In data type. It is just a ANSI format that is supported in oracle. The oracle representation of INTEGER is NUMBER (38). Use NUMBER datatype instead.

CREATE TABLE publishers(
     name VARCHAR2(50) PRIMARY KEY, 
     address VARCHAR2(50), 
     phone NUMBER(10)
);

Upvotes: 1

Justin Cave
Justin Cave

Reputation: 231851

The integer data type does not use a length qualifier. integer is equivalent to number(38,0).

SQL> ed
Wrote file afiedt.buf

  1  create table PUBLISHERS (
  2  NAME varchar2(50) primary key,
  3  address varchar2(50),
  4  phone integer
  5* )
SQL> /

Table created.

If you want to limit the size, use a number

SQL> ed
Wrote file afiedt.buf

  1  create table PUBLISHERS (
  2  NAME varchar2(50) primary key,
  3  address varchar2(50),
  4  phone number(10)
  5* )
SQL> /

Table created.

Since you are never going to do numeric operations on a phone number, however, while it is generally likely that you will perform string manipulation on it to format phone numbers for display, it would generally make sense to store a phone number as a character string rather than as a number. You can add a CHECK constraint that ensures the format is correct.

SQL> ed
Wrote file afiedt.buf

  1  create table PUBLISHERS (
  2  NAME varchar2(50) primary key,
  3  address varchar2(50),
  4  phone varchar2(10)
  5* )
SQL> /

Table created.

Upvotes: 4

Related Questions