Akka Jaworek Akka Jaworek - 4 months ago 9
MySQL Question

MySQL to Oracle database query

I have created a MySQL database in which I have successfully executed the following query:

CREATE TABLE `Person`
(
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL DEFAULT '',
`country` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;


which created a table.

Now I want to create identical table in an Oracle c11 database. Server and database are ready to take queries, however when I use the same query from MySQL I get syntax errors. How should this query look in Oracle database? I use Oracle SQL Developer.

Answer

This is what the query should look like

CREATE TABLE Person (
  id number NOT NULL PRIMARY KEY ,
  name varchar(20)  DEFAULT '' NOT NULL,
  country varchar(20) DEFAULT NULL
);

You need to create sequence and trigger for auto-increment or increase this manually in your code by calling sequence.nextval

Comments