-2

I have the following SQL code written in Oracle SQL developer:

CREATE TABLE students
(
student_id INT NOT NULL,
username VARCHAR2(30),
email VARCHAR2(80),
password VARCHAR2(30),
f_name VARCHAR2(30),
l_name VARCHAR2(30),
bio VARCHAR2(350),
dp VARCHAR2(15),
is_suspended CHAR(1) DEFAULT '0' NOT NULL,
suspension_reason VARCHAR2(150),
created_on TIMESTAMP DEFAULT SYSDATE NOT NULL,
updated_on TIMESTAMP,
is_active CHAR(1) DEFAULT '1' NOT NULL,
city VARCHAR2(15) NOT NULL,
state VARCHAR2(15) NOT NULL,
zip VARCHAR(6) NOT NULL,
b_day DATE,
role_id INT NOT NULL,
CONSTRAINT students_id_pk PRIMARY KEY(student_id),
CONSTRAINT students_role_id_fk FOREIGN KEY(role_id) REFERENCES user_roles(role_id),
CONSTRAINT students_username_uq UNIQUE(username),
CONSTRAINT students_email_uq UNIQUE(email)
);

It was written in Oracle but I need to run this in MySQL.

How can I convert the syntax to MySQL?

2
  • What problem do you have exactly? Did you run it in MySQL and you got an error? Mar 26, 2016 at 21:26
  • Why don't you use MySQL Workbench - it will point out SQL errors. You can also follow @TimPenner's suggestion about SQLFiddle. Mar 26, 2016 at 21:52

1 Answer 1

2

According to SQLfifdle the code you posted appears to be valid for MySQL 5.6

You can use SQLfiddle to check the validity of your code against multiple SQL vendors.

1
  • +1 for the SQLFiddle - obviously it's used for testing SQL against a given server, but good one on the cross checking of syntax! Mar 26, 2016 at 21:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.