0

I'm getting a syntax error on a create table string. I've had a look online to see if there's anything I'm missing but I can't spot what's wrong.

//SQL Statement to create table on phpmyadmin if not exists
    String createTable = "CREATE TABLE IF NOT EXISTS user(\n"
            + "id INT NOT NULL AUTO INCREMENT \n"
            + "username VARCHAR(20) NOT NULL \n"
            + "realname VARCHAR(100) NOT NULL \n"
            + "password VARCHAR(100) NOT NULL \n"
            + "email VARCHAR(100) NOT NULL \n"
            + "gym VARCHAR(100) \n"
            + "belt VARCHAR(100) \n"
            + "dateofbirth DATE NOT NULL \n"
            + "profilepic LONGBLOB \n"
            + "biography VARCHAR(1000) \n"
            + "motto VARCHAR(200) \n"
            + "PRIMARY KEY (id)\n"
            + ")";

Output says;

"near 'AUTO INCREMENT
username VARCHAR(20) NOT NULL
realname VARCHAR(100) NOT NULL
p' at line 2"

1
  • 1
    Shouldn't there be commas between your column declarations? Commented Dec 1, 2018 at 19:41

1 Answer 1

1

Drop all \n and replace with , after each column except for the last.
Also for MySql it's AUTO_INCREMENT, not AUTO INCREMENT.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.