上传数据库错误

时间:2016-04-27 03:27:19

标签: mysql sql create-table

上传数据库时出现以下错误

  

第53行出错:)ENGINE = MyISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT = 2;

查询:

CREATE TABLE IF NOT EXISTS `wpcads_paypal` (
 `main_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
 `user_id` text NOT NULL,
 `transaction_id` text NOT NULL,
 `firstname` text NOT NULL,
 `lastname` text NOT NULL,
 `email` text NOT NULL,
 `description` text NOT NULL,
 `summary` text NOT NULL,
 `created` int(4) unsigned NOT NULL,
 PRIMARY KEY (`main_id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2

MySQL:

  

您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以便在'--------------------------------附近使用正确的语法------------------------ - - CREATE TABLE IF N'在第4行

     

错误时停止

3 个答案:

答案 0 :(得分:1)

我试过这个代码表完全成功了:

CREATE TABLE IF NOT NOT EXISTS wpcads_paypal( main_id BIGINT(20)UNSIGNED NOT NULL AUTO_INCREMENT, user_id TEXT NOT NULL, transaction_id TEXT NOT NULL, 名字TEXT NOT NULL, 姓氏TEXT NOT NULL, 电子邮件TEXT NOT NULL, description TEXT NOT NULL, 摘要TEXT NOT NULL, 创建INT(4)UNSIGNED NOT NULL, PRIMARY KEY(main_id)

答案 1 :(得分:1)

此代码中未发现任何错误:

CREATE TABLE IF NOT EXISTS wpcads_paypal( main_id BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT , user_id TEXT NOT NULL , transaction_id TEXT NOT NULL , firstname TEXT NOT NULL , lastname TEXT NOT NULL , email TEXT NOT NULL , description TEXT NOT NULL , summary TEXT NOT NULL , created INT( 4 ) UNSIGNED NOT NULL , PRIMARY KEY ( main_id )

答案 2 :(得分:0)

我已为您提到的同一查询创建了一个表格 这很好(你的查询没有错)

查询中的额外字符一定是问题所在,只需立即复制查询并尝试创建表格

mysql>  CREATE TABLE IF NOT EXISTS wpcads_paypal (  main_id bigint(20)   
unsigned NOT NULL AUTO_INCREMENT,  user_id text NOT NULL,  transaction_id text NOT NULL,  firstname text NOT NULL,  
lastname text NOT NULL,  email text NOT NULL,  description text NOT NULL,  summary text NOT NULL,  created int(4) 
unsigned NOT NULL, PRIMARY KEY (main_id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2;
Query OK, 0 rows affected (0.06 sec)

mysql> desc wpcads_paypal;
+----------------+---------------------+------+-----+---------+----------------+
| Field          | Type                | Null | Key | Default | Extra          |
+----------------+---------------------+------+-----+---------+----------------+
| main_id        | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| user_id        | text                | NO   |     | NULL    |                |
| transaction_id | text                | NO   |     | NULL    |                |
| firstname      | text                | NO   |     | NULL    |                |
| lastname       | text                | NO   |     | NULL    |                |
| email          | text                | NO   |     | NULL    |                |
| description    | text                | NO   |     | NULL    |                |
| summary        | text                | NO   |     | NULL    |                |
| created        | int(4) unsigned     | NO   |     | NULL    |                |
+----------------+---------------------+------+-----+---------+----------------+
9 rows in set (0.01 sec)