使用mysql创建表时出错?

时间:2016-10-05 09:55:46

标签: mysql

我不知道我在创建下表时犯了什么错误?

create table users(Time int(11) not NULL,
             userid text,group text,
             jobs_running int(11),
             jobs_pending int(11),
             job_limit int(11),
             run_failures int(11),
             queues text,
             ATP int(11),
             pend_reasons int(11));

4 个答案:

答案 0 :(得分:3)

只需做一个简单的引号,这将使您的查询运行,无需更改列名称 下面是运行查询 注意

create table users(Time int(11) not NULL,userid text,`group` text,jobs_running int(11),jobs_pending int(11),job_limit int(11),run_failures int(11),queues text,ATP int(11),pend_reasons int(11));

答案 1 :(得分:1)

将列名称组重命名为任何其他名称。这是一个关键字因此给出错误。

试试这个。

 create table users(Time int(11) not NULL,
                 userid text,
                 groups text,
                 jobs_running int(11),
                 jobs_pending int(11),
                 job_limit int(11),
                 run_failures int(11),
                 queues text,
                 ATP int(11),
                 pend_reasons int(11));

答案 2 :(得分:1)

这是Mimer SQL-2003 Validator所说的:

create table users(Time int(11) not NULL,userid text,group text,jobs_running
                   ^----                             ^--- 
 int(11),jobs_pending int(11),job_limit int(11),run_failures int(11),queues

 text,ATP int(11),pend_reasons int(11));

syntax error: Time
  correction: <identifier>
syntax error: group
  correction: <identifier>

答案 3 :(得分:1)

这是一般性问题,当我们使用一些mysql或任何与数据库管理系统相关的单词时,会产生很多时间。表格字段的分组,日期等。 这里的问题是你对表字段使用“组”字。你只需要反击(`)。请注意以下查询:

create table users(Time int(11) not NULL,userid text,`group` text,jobs_running int(11),jobs_pending int(11),job_limit int(11),run_failures int(11),queues text,ATP int(11),pend_reasons int(11))
相关问题