-2

I can't for the life of me figure out what's wrong with this query:

CREATE TABLE IF NOT EXISTS 'plaintext' (
 'id' INT NOT NULL AUTO_INCREMENT,
 'name' VARCHAR NOT NULL,
 'text' TEXT NOT NULL,
 PRIMARY KEY ('id')
)

I am running MySQL version 5.7.14 on WAMP. I am getting this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''id' INT NOT NULL AUTO_INCREMENT, 'name' VARCHAR NOT NULL, 'text' TEX' at line 2

When trying out the query in phpmyadmin it told me that a symbol name and column definition was expected near 'id' on line 2, and there is an unexpected beginning of a statement near 'id' at line 5.

No clue what this even means to be completely honest with you, I'm quite new to MySQL.

Thanks in advance!

David

David C
  • 23
  • 5

1 Answers1

0

I think that the issue is that you are not providing a size for your VARCHAR

CREATE TABLE IF NOT EXISTS 'plaintext' (
 'id' INT NOT NULL AUTO_INCREMENT,
 'name' VARCHAR(100) NOT NULL,
 'text' TEXT NOT NULL,
 PRIMARY KEY ('id')

)

valanto
  • 893
  • 3
  • 8
  • 23
  • This was indeed the problem, I guess the error checking for phpmyadmin just sucks. Why is it required to specify a size for a varchar? Why doesn't it just default to the maximum? – David C Aug 02 '17 at 09:13