Search code examples
mysqlphpmyadmincreate-table

Syntax error after show create table in mysql


I just want to copy an existing table structure into another database. All queries are executed in phpmyadmin:

I first execute:

SHOW CREATE TABLE keyword_session

Then I execute the output of it in another database:

CREATE TABLE `keyword_session` (  
`id` int(11) NOT NULL AUTO_INCREMENT, 
`session_id` int(11) NOT NULL,
`keyword_id` int(11) NOT NULL,  PRIMARY KEY (`id`))
ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1

And I got the 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 'id int(11) NOT NULL AUTO_INCREMENT, Â session_id int(11) NOT NULL, Â `keywor' at line 1

Where is the syntax error ? Isn't SHOW CREATE TABLE be a result that you can execute ?


Edit: Some information on the system where I try to create the table:

Database server :
  Server: Localhost via UNIX socket
  Software: MySQL
  Software version: 5.1.63-0ubuntu0.11.10.1 - (Ubuntu)
  Protocol version: 10
  User: ...
  Server charset: UTF-8 Unicode (utf8)
Web server:
  ...
phpMyAdmin:
  Version information: 3.5.1, latest stable version: 3.5.5
  ...

Solution

  • According to the error, your statement seems to have unknown symbol  in it.

    Probably, your new-line feed is misinterpreted. I say so, because it is noticeable at the line ends only:

    id int(11) NOT NULL AUTO_INCREMENT, Â session_id int(11) NOT NULL, Â `keywor
    

    notice how the symbol appears before session_id and keyword_id declaration?