Home > Software design >  Creating table at SQL developer despite making sure the code is correct
Creating table at SQL developer despite making sure the code is correct

Time:10-05

I am new to using SQL developer, I have tried to create a simple table but keep recieving a synatx error. I have written :

CREATE TABLE customer(
    id Int(11),
    first_name VARCHAR(30),
    last_name VARCHAR(30),
    email VARCHAR(60),
    adress VARCHAR(60),
    phone VARCHAR(8)
);

I keep recieving : Error starting at line : 3 in command - ORA-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis" *Cause:
*Action:

Can someone tell me what's wrong please?

CodePudding user response:

  CREATE TABLE customer
  (
    id NUMBER(4),
    first_name VARCHAR(30),
    last_name VARCHAR(30),
    email VARCHAR(60),
    adress VARCHAR(60),
    phone VARCHAR(8) 
  );

OR

  CREATE TABLE customer
  (
    id INT,
    first_name VARCHAR(30),
    last_name VARCHAR(30),
    email VARCHAR(60),
    adress VARCHAR(60),
    phone VARCHAR(8) 
  );

CodePudding user response:

It is just that INT - if used in Oracle - doesn't allow precision. So, instead of int(11), use int alone:

SQL> CREATE TABLE customer
  2  (
  3     id           INT,
  4     first_name   VARCHAR (30),
  5     last_name    VARCHAR (30),
  6     email        VARCHAR (60),
  7     adress       VARCHAR (60),
  8     phone        VARCHAR (8)
  9  );

Table created.

SQL>

If you want to include precision, then use number(11).

  • Related