phpMyAdmin - 导入失败#1064 - 在'INSERT INTO附近使用正确的语法

时间:2016-10-26 08:31:00

标签: mysql database

我正在尝试将.sql文件导入phpMyAdmin表。

上面的错误是不可思议的,因为它看起来好像停在我文件的“R”部分。

我附上了截图以及我正在尝试导入的文件。任何帮助都会非常感激。

enter image description here

INSERT INTO `tallmanc_TestApi`.`WeeklySchedule`
    (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`)
    VALUES (`1`,`0`,`0`,`24`,`TestData`)

INSERT INTO `tallmanc_TestApi`.`WeeklySchedule`
    (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`)
    VALUES (`2`,`1`,`1`,`22`,`TestData`)

INSERT INTO `tallmanc_TestApi`.`WeeklySchedule`
    (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`)
    VALUES (`3`,`2`,`2`,`8`,`TestData`)

INSERT INTO `tallmanc_TestApi`.`WeeklySchedule`
    (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`)
    VALUES (`4`,`3`,`3`,`21`,`TestData`)

INSERT INTO `tallmanc_TestApi`.`WeeklySchedule`
    (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`)
    VALUES (`5`,`1`,`0`,`24`,`TestData`)

INSERT INTO `tallmanc_TestApi`.`WeeklySchedule`
    (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`)
    VALUES (`6`,`2`,`1`,`8`,`TestData`)

INSERT INTO `tallmanc_TestApi`.`WeeklySchedule`
    (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`)
    VALUES (`7`,`3`,`2`,`20`,`TestData`)

INSERT INTO `tallmanc_TestApi`.`WeeklySchedule`
    (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`)
    VALUES (`8`,`4`,`3`,`32`,`TestData`)

INSERT INTO `tallmanc_TestApi`.`WeeklySchedule`
    (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`)
    VALUES (`9`,`2`,`0`,`7`,`TestData`)

INSERT INTO `tallmanc_TestApi`.`WeeklySchedule`
    (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`)
    VALUES (`10`,`3`,`1`,`22`,`TestData`)

INSERT INTO `tallmanc_TestApi`.`WeeklySchedule`
    (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`)
    VALUES (`11`,`4`,`2`,`25`,`TestData`)

INSERT INTO `tallmanc_TestApi`.`WeeklySchedule`
    (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`)
    VALUES (`12`,`5`,`3`,`21`,`TestData`)

INSERT INTO `tallmanc_TestApi`.`WeeklySchedule`
    (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`)
    VALUES (`13`,`3`,`0`,`30`,`TestData`)

INSERT INTO `tallmanc_TestApi`.`WeeklySchedule`
    (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`)
    VALUES (`14`,`4`,`1`,`25`,`TestData`)

1 个答案:

答案 0 :(得分:0)

反向标记主要用于表和列标识符。仅当标识符包含空格或MySQL保留字时才需要。 单引号用于在VALUES()列表中包含字符串文字。虽然MySQL支持双引号,但单引号在所有RDBMS中被广泛接受。因此,将值括在单引号内是一种很好的做法。

MySQL期望将DATE和DATETIME文字值括在单引号内(尽管双引号可以正常工作)。

所以,如果表&列标识符除了[a-z,A-Z,0-9,$ _]之外不包含任何特殊字符,您可以不加引号。 VALUES()列表中的字符串文字值必须用单引号括起来。您可以使用双引号括起单引号(')。

点击此处When to use single quotes, double quotes, and backticks in MySQLUsing backticks around field names

在phpmyadmin中尝试此查询。到最后一列,你应该用quote括起来,并在每个语句的末尾给出分号。

INSERT INTO tallmanc_TestApi.WeeklySchedule (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`) VALUES (2,1,1,22,'TestData'); 
INSERT INTO tallmanc_TestApi.WeeklySchedule (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`) VALUES (3,2,2,8,'TestData'); 
INSERT INTO tallmanc_TestApi.WeeklySchedule (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`) VALUES (4,3,3,21,'TestData'); 
INSERT INTO tallmanc_TestApi.WeeklySchedule (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`) VALUES (5,1,0,24,'TestData'); 
INSERT INTO tallmanc_TestApi.WeeklySchedule (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`) VALUES (6,2,1,8,'TestData'); 
INSERT INTO tallmanc_TestApi.WeeklySchedule (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`) VALUES (7,3,2,20,'TestData'); 
INSERT INTO tallmanc_TestApi.WeeklySchedule (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`) VALUES (8,4,3,32,'TestData'); 
INSERT INTO tallmanc_TestApi.WeeklySchedule (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`) VALUES (9,2,0,7,'TestData'); 
INSERT INTO tallmanc_TestApi.WeeklySchedule (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`) VALUES (10,3,1,22,'TestData'); 
INSERT INTO tallmanc_TestApi.WeeklySchedule (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`) VALUES (11,4,2,25,'TestData'); 
INSERT INTO tallmanc_TestApi.WeeklySchedule (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`) VALUES (12,5,3,21,'TestData'); 
INSERT INTO tallmanc_TestApi.WeeklySchedule (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`) VALUES (13,3,0,30,'TestData'); 
INSERT INTO tallmanc_TestApi.WeeklySchedule (`Id`, `Day_Id`, `Meal_Type`, `RecipeId`, `Schedule_Type`) VALUES (14,4,1,25,'TestData');