-6
CREATE TABLE STUDENT
(
    STUDENT_NAME CHAR(20),
    FATHER_NAME CHAR(20),
    ENROLL_NO INT(12),
    PHONE_NO INT(12),
    EMAIL_ID CHAR(20),
    ADDRESS CHAR(20),
    COURSE CHAR(20),
    D_O_B DATE,
);

My above table showing this error

Error report - ORA-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis"

I am not able to understand which right parenthesis is missing.

tadman
  • 208,517
  • 23
  • 234
  • 262

3 Answers3

2

Just remove tha comma (,) from last line

This is your correct code (MySQL)

CREATE TABLE STUDENT
(
      STUDENT_NAME CHAR(20),
      FATHER_NAME CHAR(20),
      ENROLL_NO INT(12),
      PHONE_NO INT(12),
      EMAIL_ID CHAR(20),
      ADDRESS CHAR(20),
      COURSE CHAR(20),
      D_O_B DATE
);

Update :: INT is not supported by oracle. user NUMBER data type instead.

This is the updated code of oracle

CREATE TABLE STUDENT_TABLE
(
  STUDENT_NAME CHAR(20),
  FATHER_NAME CHAR(20),
  ENROLL_NO NUMBER(10),
  PHONE_NO NUMBER(10),
  EMAIL_ID VARCHAR(20),
  ADDRESS VARCHAR(20),
  COURSE VARCHAR(20),
  D_O_B DATE
);
Vikash
  • 3,391
  • 2
  • 23
  • 39
  • Its still showing error. Error starting at line : 1 in command - CREATE TABLE STUDENT ( STUDENT_NAME CHAR(20), FATHER_NAME CHAR(20), ENROLL_NO INT(12), PHONE_NO INT(12), EMAIL_ID CHAR(20), ADDRESS CHAR(20), COURSE CHAR(20), D_O_B DATE ) Error report - ORA-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis" *Cause: *Action: – Rishu Sinha Apr 03 '18 at 15:13
  • You copy my exact code, its working. check this link - http://www.sqlfiddle.com/#!9/ed7fef – Vikash Apr 03 '18 at 15:15
  • The error is oracle and fails in sqlfiddle when set to oracle. – P.Salmon Apr 03 '18 at 15:24
1

Tried this on my end.It works for me.

CREATE TABLE STUDENT_TABLE
(
  STUDENT_NAME CHAR(20),
  FATHER_NAME CHAR(20),
  ENROLL_NO NUMBER(10),
  PHONE_NO NUMBER(10),
  EMAIL_ID VARCHAR(20),
  ADDRESS VARCHAR(20),
  COURSE VARCHAR(20),
  D_O_B DATE
);
vithika
  • 213
  • 1
  • 5
  • 16
0

Oracle? Get rid of CHAR and VARCHAR datatypes and use VARCHAR2 instead.

SQL> CREATE TABLE STUDENT
  2    ( STUDENT_NAME VARCHAR2(20),
  3      FATHER_NAME  VARCHAR2(20),
  4      ENROLL_NO    NUMBER(12),
  5      PHONE_NO     NUMBER(12),
  6      EMAIL_ID     VARCHAR2(20),
  7      ADDRESS      VARCHAR2(20),
  8      COURSE       VARCHAR2(20),
  9      D_O_B        DATE
 10  );

Table created.

SQL>

Apart from that, that table doesn't have a primary key defined and - in my opinion - it should. A few NOT NULL constraints (for example, on STUDENT_NAME) might be a good choice.

On a second thought, why STUDENT_NAME? It isn't normalized - should be split to (at least) STUDENT_FIRST_NAME and STUDENT_LAST_NAME.

Someone (@Vikash, who posted a message 3 hours ago)) said that Oracle doesn't support INT datatype; well, it does, but you'd rather use NUMBER:

SQL> create table test
  2    (phone_no int);

Table created.

but you can't set its precision:

SQL> create table test_2
  2    (phone_no int(12));
  (phone_no int(12))
               *
ERROR at line 2:
ORA-00907: missing right parenthesis


SQL>

so - in your code - use either INT or NUMBER(12), but beware of unexpected traps (i.e. rounding), such as

SQL> create table test
  2    (num1 int,
  3     num2 number(12));

Table created.

SQL> insert into test values (123.456, 123.456);

1 row created.

SQL> select * From test;

      NUM1       NUM2
---------- ----------
       123        123

SQL>
Littlefoot
  • 131,892
  • 15
  • 35
  • 57