Home:ALL Converter>I keep getting parenthesis error in SQL Oracle when introducing a foreign key

I keep getting parenthesis error in SQL Oracle when introducing a foreign key

Ask Time:2021-03-13T12:10:00         Author:Wietlol

Json Formatter

I have been searching and playing around with the code trying to figure out why its giving me parenthesis error when I followed the format of Oracle referencing in other tables

Create table TourOperator (TOID int PRIMARY KEY, Cname varchar (20), phone long int);

Create table Airline(Aname varchar(20) PRIMARY KEY, Website varchar(255), Phone int(10), TOID int, FOREIGN KEY(TOID) REFERENCES TourOperator);

Author:Wietlol,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/66610053/i-keep-getting-parenthesis-error-in-sql-oracle-when-introducing-a-foreign-key
The Impaler :

You have a few issues in your SQL, according to the Oracle syntax:\n\nThe type INT cannot be qualified with a size.\nThe type VARCHAR technically does exist in Oracle, but is not recommended; use VARCHAR2 instead.\nThe syntax of the foreign key clause is wrong.\nAvoid the type LONG; it's a legacy type that you shouldn't use for new databases. I changed the phone column to VARCHAR2.\n\nThe SQL can run as:\nCreate table TourOperator (\n TOID int PRIMARY KEY, \n Cname varchar2(20), \n phone varchar2(20)\n);\n\nCreate table Airline(\n Aname varchar2(20) PRIMARY KEY, \n Website varchar2(255), \n Phone int, \n TOID int REFERENCES TourOperator (TOID)\n);\n\nSee running example at db<>fiddle.",