有什么问题这个create table语句(复制)What is wrong with this create table statement [duplicate]

- 此内容更新于:2014-12-30
主题:

原文:

This question already has an answer here:

Does anyone have any idea what is wrong with this create statement for mysql?

EDIT: now it states the error is near: revised VARCHAR(20), paypal_accept TINYINT, pre_terminat' at line 4

Thanks for the help everyone

Still errors after using sql beautifier though

CREATE TABLE AUCTIONS (
  ARTICLE_NO      VARCHAR(20),
  ARTICLE_NAME    VARCHAR(100),
  SUBTITLE        VARCHAR(20),
  CURRENT_BID     VARCHAR(20),
  START_PRICE     VARCHAR(20),
  BID_COUNT       VARCHAR(20),
  QUANT_TOTAL     VARCHAR(20),
  QUANT_SOLD      VARCHAR(20),
  START           DATETIME,
  ENDS            DATETIME,
  ORIGIN_END      DATETIME,
  SELLER_ID       VARCHAR(20),
  BEST_BIDDER_ID  VARCHAR(20),
  FINISHED        VARCHAR(20),
  WATCH           VARCHAR(20),
  BUYITNOW_PRICE  VARCHAR(20),
  PIC_URL         VARCHAR(20),
  PRIVATE_AUCTION VARCHAR(20),
  AUCTION_TYPE    VARCHAR(20),
  INSERT_DATE     DATETIME,
  UPDATE_DATE     DATETIME,
  CAT_1_ID        VARCHAR(20),
  CAT_2_ID        VARCHAR(20),
  ARTICLE_DESC    VARCHAR(20),
  DESC_TEXTONLY   VARCHAR(20),
  COUNTRYCODE     VARCHAR(20),
  LOCATION        VARCHAR(20),
  CONDITION       VARCHAR(20),
  REVISED         VARCHAR(20),
  PAYPAL_ACCEPT   TINYINT,
  PRE_TERMINATED  VARCHAR(20),
  SHIPPING_TO     VARCHAR(20),
  FEE_INSERTION   VARCHAR(20),
  FEE_FINAL       VARCHAR(20),
  FEE_LISTING     VARCHAR(20),
  PIC_XXL         TINYINT,
  PIC_DIASHOW     TINYINT,
  PIC_COUNT       VARCHAR(20),
  ITEM_SITE_ID    VARCHAR(20),
    PRIMARY KEY ( `ARTICLE_NO` ));

The error is now near 'CONDITION VARCHAR(20), REVISED VARCHAR(20), PAYPAL_ACCEPT TI' at line 29

I really can't see what is wrong, does TINYINT need a parameter?

Do MYSQL column names have to be capitals?

Tom H.的回复:以防你# 39;不知道如何将其格式化杰克,还有# 39;年代“code"按钮(看上去像二进制)上面文本框。选择您的代码,然后单击按钮。否则,空格为# 39;t妥善保存。

(原文:In case you're not aware how to format it Josh, there's a "code" button (looks like binary) above the post text box. Select your code and click that button. Otherwise, whitespace isn't properly preserved.)

S.Lott的回复:@John希恩——删除代码,并# 39;t。只显示代码,实际问题实际帮助你真正想要的。

(原文:@John Sheehan -- delete code that doesn't matter. Only show the code that has the actual problem you actually want actual help with.)

谢谢你建议每一个人。

(原文:Thankyou for the tips everyone.)

Dave的回复:退出编辑问题。现在没有任何意义的答案。如果你有编辑,添加一个更新部分。

(原文:Quit editing the question. None of the answers make any sense now. If you have to edit, add an update section.)

S.Lott的回复:我投票我们关闭问题,摆脱它。也许更明智的版本重新开始。

(原文:I vote we close the question and get rid of it. Perhaps begin again with a more sensible version.)

解决方案:
我相信列名“开始”和“条件”是在MySQL‘特殊’字吗?我所做的只是美化代码粘贴到浏览器查询,发现有些列名“蓝”……:P
原文:

I believe the column names "START" and "CONDITION" are 'special' words in MySQL? All I did was simply paste the beautified code into Query Browser and noticed that some column names were 'blue'... :P

解决方案:
手表和auction_type之间你错过了一个列名。只有varchar(20),删除,或添加丢失的列名。
原文:
watch VARCHAR(20),  **????** VARCHAR(20), 
auction_type VARCHAR(20),

Between watch and auction_type you have missed a column name. Only the varchar(20) is there, either delete that or add in missing column name.

解决方案:
从: pic_count VARCHAR(20)、item_site_id); item_site_id似乎没有一个类型。给它一个类型和查询验证…… (测试在这里:http://www.wangz.net/cgi-bin/pp/gsqlparser/sqlpp/sqlformat.tpl寻找这些类型的错误)
原文:

From the end:

pic_count VARCHAR(20),item_site_id);

item_site_id doesn't seem to have a type. Give it a type and your query validates...

(Test it here: http://www.wangz.net/cgi-bin/pp/gsqlparser/sqlpp/sqlformat.tpl for finding these kinds of errors)

ConcernedOfTunbridgeWells的回复:+ 1。我认为这是好,正要贴出来的。

(原文:+1. I saw this as well and was just about to post it.)

解决方案:
检查你的列名的MySQL保留字列表: http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html 您将看到,条件是一个保留字。您可以使用MySQL列名的保留字,但你必须将它们包含在单引号中清楚地告诉MySQL,你不使用这个词在其常规使用。
原文:

Check your column names against the list of MySQL reserved words:

http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

You'll see that CONDITION is a reserved word. You can use MySQL reserved words for column names, but you have to enclose them in back-quotes to clearly tell MySQL that you're not using the word in its conventional use.

. . .
LOCATION    VARCHAR(20),
`CONDITION` VARCHAR(20),
REVISED     VARCHAR(20),
. . .
解决方案:
格式化。
原文:

The formatting.

解决方案:
提示:格式代码可读性。 我把你的代码和应用简单格式…… …我马上可以看到item_site_id丢失了一个数据类型。
原文:

Tip: Format code for readability.

I take your code and apply simple formatting...

CREATE TABLE auctions (
  article_no        VARCHAR(20),
  article_name      VARCHAR(100),
  subtitle          VARCHAR(20),
  current_bid       VARCHAR(20),
  start_price       VARCHAR(20),
  bid_count         VARCHAR(20),
  quant_total       VARCHAR(20),
  quant_sold        VARCHAR(20),
  start             DATETIME,
  ends              DATETIME,
  origin_end        DATETIME,
  seller_id         VARCHAR(20),
  best_bidder_id    VARCHAR(20),
  finished          VARCHAR(20),
  watch             VARCHAR(20),
  buyitnow_price    VARCHAR(20),
  pic_url           VARCHAR(20),
  private_auction   VARCHAR(20),
  auction_type      VARCHAR(20),
  insert_date       DATETIME,
  update_date       DATETIME,
  cat_1_id          VARCHAR(20),
  cat_2_id          VARCHAR(20),
  article_desc      VARCHAR(20),
  desc_textonly     VARCHAR(20),
  countrycode       VARCHAR(20),
  location          VARCHAR(20),
  condition         VARCHAR(20),
  revised           VARCHAR(20),
  paypal_accept     TINYINT,
  pre_terminated    VARCHAR(20),
  shipping_to       VARCHAR(20),
  fee_insertion     VARCHAR(20),
  fee_final         VARCHAR(20),
  fee_listing       VARCHAR(20),
  pic_xxl           TINYINT,
  pic_diashow       TINYINT,
  pic_count         VARCHAR(20),
  item_site_id
);

...and straight away I can see item_site_id is missing a data type.

解决方案:
根据MySQL保留关键字的列表,条件是一个保留字,你必须摆脱它(使用反勾号)使用它作为一个对象的名字(例如表、列、等等)。 我建议不要使用保留字作为名字的一列(即使你逃脱了它),因为会导致各种各样的问题在未来当编写查询。
原文:

According to the list of MySQL Reserved Keywords, CONDITION is a reserved keyword, and you must escape it (using back-ticks) to use it as the name of an object (e.g. table, column, etc.).

I would recommend against using a reserved keyword as a name of a column (even if you escaped it) because that causes all sorts of problems when writing queries in the future.

解决方案:
“VARCHAR(20),不指定一个名称。
原文:

"VARCHAR(20)," doesn't assign a name.

解决方案:
关于失踪的字段名称是正确的答案(如果我有代表的投票)但我也建议将以下行后“cat_2_id VARCHAR(20)”:
原文:

The answer about the missing field name is correct (would vote it up if I had the rep) but I would also recommend placing the following line after 'cat_2_id VARCHAR(20)':

PRIMARY KEY (`article_no`)
Ed Guiness的回复:“上面mine"失去上下文随着你的答案。

(原文:"Above mine" loses context as your answer moves around.)

Stephen Walcher的回复:并# 39;t知道答案了。谢谢。

(原文:Didn't realize the answers moved. Thanks.)