Alejandro
Alejandro

Reputation: 1

Transferring from sql developer to mysql

So i have a few tables in my database in Sql developer which I still have the queries from. If I try to put it in mysql it comes out with some errors so i'm wondering what is different and why is it not working like what would I need to change.

These are some of the tables I created in sql which i'm trying to create now in mysql:

create table EspecialidadesMedicas(
IdEspecialidad number(4) constraint pk_EspecialidadesMedicas primary key,
DescripcionEspecialidad varchar2(30));

create table Doctores(
IdDoctor number(5) constraint pk_Doctores primary key,
NombreDoctor varchar2(30),
Salario number(12,2),
Especialidad constraint fk1_Doctores references EspecialidadesMedicas);

create table Consultorios(
IdConsultorio number(4) constraint pk_Consultorios primary key,
Tamano varchar2(30),
Construido date);

Upvotes: 0

Views: 57

Answers (2)

Iarwa1n
Iarwa1n

Reputation: 460

Your first table would look like this in MySQL:

CREATE TABLE `de`.`EspecialidadesMedicas` (
  `IdEspecialidad` INT NOT NULL AUTO_INCREMENT,
  `DescripcionEspecialidad` VARCHAR(30) NULL,
  PRIMARY KEY (`IdEspecialidad`));

As you see, there are quite some differences in syntax, data types and features which can not all be covered here. (e.g. AUTO INCREMENT) The easiest way to get into this is to use a toollike MySQL Workbench. It allows you to use a GUI to create your tables and displays the executed SQL. This way you see the differences.

I also suggest to read some migration tutorials like these:

https://blog.toadworld.com/2017/03/17/migrating-from-oracle-to-mysql

http://www.sqlines.com/oracle-to-mysql

Upvotes: 0

zedfoxus
zedfoxus

Reputation: 37049

Your first statement will become this:

create table EspecialidadesMedicas(
  IdEspecialidad int primary key,
  DescripcionEspecialidad varchar(30)
);

Your second statement is likely to become this:

create table Doctores(
    IdDoctor int primary key,
    NombreDoctor varchar(30),
    Salario decimal(12,2),
    Especialidad int,
    constraint fk1_Doctores foreign key (Especialidad) references EspecialidadesMedicas (IdEspecialidad)
);

Your third statement will turn out to be:

create table Consultorios(
    IdConsultorio int primary key,
    Tamano varchar(30),
    Construido date
);

Try this out in MySQL.

Upvotes: 1

Related Questions