【问题标题】:MySQL error 1064 table creationMySQL 错误 1064 表创建
【发布时间】:2017-07-09 18:37:58
【问题描述】:

这似乎是一个相当微不足道的问题,但我在运行以下查询时运气不佳:

create table if not exists tweet_data (
created_at DATETIME,
user_name VARCHAR(20),
retweet_count INT,
favourite_count INT,
tweet_followers_count INT,
is_retweet BOOLEAN,
tweet_source VARCHAR(256),
user_location VARCHAR(256),
tweet_mentioned_count INT,
tweet_ID VARCHAR(256) NOT NULL,
tweet_text VARCHAR(140),
UNIQUE (tweet_ID) );

当我运行它时,我收到以下错误消息:

Error Code: 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 '(20),  retweet_count INT,     favourite_count INT,     
tweet_followers_count ' at line 3

当我将鼠标悬停在第 3 行的错误标签上时,它会显示:

Syntax error : unexpected '(' (opening parenthesis)

我相信这是一个简单的修复,任何帮助都会很棒!

【问题讨论】:

  • 应该是user_name VARCHAR(20),R和(之间没有空格
  • 不是因为 (20) 中的空格和 user_name 列中的 VARCHAR 吗?
  • 试过这个,不幸的是仍然得到同样的错误。将编辑以删除上面的空间。

标签: mysql syntax-error mysql-error-1064


【解决方案1】:

原来是 mySQL Workbench 出错

【讨论】:

    【解决方案2】:
    create table if not exists  tweet_data (
    
    created_at DATETIME,
    
    user_name VARCHAR (20),
    
    retweet_count INT,
    
    favourite_count INT,
    
    tweet_followers_count INT,
    
    is_retweet BOOLEAN,
    
    tweet_source VARCHAR(256),
    
    user_location VARCHAR(256),
    
    tweet_mentioned_count INT,
    
    tweet_ID VARCHAR(256) NOT NULL,
    
    tweet_text VARCHAR(140),
    
    UNIQUE (tweet_ID) );
    

    这段代码运行完美。

    转到此链接并自行检查

    http://rextester.com/l/mysql_online_compiler

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-03
      • 2018-01-26
      • 1970-01-01
      • 2011-04-17
      • 1970-01-01
      • 2013-01-17
      • 1970-01-01
      相关资源
      最近更新 更多