0

I am trying to create a table and getting error as ora 00907 missing right parenthesis. What went wrong?

This is my query:

CREATE TABLE College (
    ID int, 
    NAME varchar(255), 
    Branch var char(255) NOT NULL,
    Percentage int, 
    Address varchar, 
    City varchar(255),
    PRIMARY KEY (ID)
);
Massimiliano Kraus
  • 3,638
  • 5
  • 27
  • 47
Dinesh
  • 1
  • 1
    check type of `Branch` column – demo Aug 19 '17 at 20:29
  • 1
    You can check the answer on this [subject](https://stackoverflow.com/questions/24580780/ora-00907-missing-right-parenthesis) it may help you. – Purple Haze Aug 19 '17 at 20:32
  • Var char, varchar and syntax walked into a bar. They left shortly after. Only one space left. – bastijn Aug 19 '17 at 21:46
  • Two errors: (1) `var char` after `Branch` should be `varchar`. (2) you must provide a size for the `Address` (currently, `varchar` without a size). – FDavidov Aug 20 '17 at 11:32

1 Answers1

1

You have multiple errors. Presumably, you want something like this:

CREATE TABLE Colleges (
    CollegeID int PRIMARY KEY,
    Name varchar2(255),
    Branch varchar2(255) NOT NULL,
    Percentage int,
    Address varchar2(255),
    City varchar2(255)
);

Notes:

  • Your syntax problem is the space in var char.
  • Oracle recommends varchar2() over varchar.
  • You should always include a length in the definition.
  • You can inline the primary key definition.
  • I prefer that the primary key include the entity name, rather than the generic id.
  • Similarly, I prefer that the table be in the plural, because it contains multiple colleges.
  • A column called percentage with a type of int is suspicious.
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786