Search code examples
mysqlcreate-table

mysql create table ... what am i doing wrong


  CREATE TABLE 'behandelingen' (
  'behandeling_id' int(10) NOT NULL auto_increment,
  'behandeling' varchar(35) NOT NULL default '',
  'kosten' float NOT NULL default '0',
  'bank_reknr' varchar(20) NOT NULL default '',
  PRIMARY KEY  ('behandeling_id'),
  UNIQUE KEY 'behandeling' ('behandeling')
);

Trying to import a database / tables to a my local server using phpmyadmin. I keep coming up with the following error

1064 - 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 ''behandelingen' ( 'behandeling_id' int(10) NOT NULL auto_increment, 'behan' at line 1 Static analysis:

4 errors were found during analysis.

A symbol name was expected! (near "'behandeling_id'" at position 34)
At least one column definition was expected. (near "'behandeling_id'" at position 34)
Unexpected beginning of statement. (near "10" at position 55)
Unrecognized statement type. (near "NOT NULL" at position 59)

can some one shed some light on it ... I am using Server version: 5.7.14 - MySQL Community Server (GPL)


Solution

  • Use backticks instead of single quotes on the table name and column names. See below:

    CREATE TABLE `behandelingen` (
        `behandeling_id` int(10) NOT NULL auto_increment,
        `behandeling` varchar(35) NOT NULL default '',
        `kosten` float NOT NULL default '0',
        `bank_reknr` varchar(20) NOT NULL default '',
        PRIMARY KEY  (`behandeling_id`),
        UNIQUE KEY `behandeling` (`behandeling`)
    );