简体   繁体   English

无法在phpMyAdmin中保存表

[英]Cannot save a table in phpMyAdmin

Currently training on phpMyAdmin, and tried to set up my first set of fields in the database. 目前正在对phpMyAdmin进行培训,并尝试在数据库中设置我的第一组字段。 After I set the fields' names, types, and values, I tried to save and phpMyAdmin returned error: 在设置字段的名称,类型和值后,我尝试保存并且phpMyAdmin返回错误:

Error SQL query: 错误SQL查询:

CREATE TABLE  `test`.`Contact ` (
`Contact` INT NOT NULL ,
`Name` VARCHAR( 50 ) NOT NULL ,
`Company` VARCHAR( 30 ) NOT NULL ,
`Email` VARCHAR( 50 ) NOT NULL
) ENGINE = MYISAM CHARACTER SET ASCII COLLATE ascii_general_ci;
MySQL said: Documentation
#1103 - Incorrect table name 'Contact ' 

Can anyone help to find out what the problem is? 任何人都可以帮助找出问题所在?

The space character after the table name is what's causing the error. 表名后的空格字符是导致错误的原因。 From MySQL documentation : 来自MySQL文档

Database, table, and column names cannot end with space characters 数据库,表和列名称不能以空格字符结尾

Table name can not contain spaces! 表名不能包含空格! You have a whitespace after Contact: << test . 在Contact:<< test之后你有一个空格。 Contact (>> Contact (>>

To get this to work you need to remove the space from your table name. 要使其工作,您需要从表名中删除空格。

As a matter of convention, I would also suggest that you change the name of the Contact field to something more meaningful. 作为惯例,我还建议您将Contact字段的名称更改为更有意义的名称。 I'm assuming that you want to make that your primary key. 我假设你想把它作为你的主键。 You should probably name it simply 'id'. 你应该把它命名为'id'。 You'll also want to set the auto increment and primary key checkboxes so that the field works as you want it to. 您还需要设置自动增量和主键复选框,以便字段按您的需要工作。

The primary key setting makes queries run MUCH faster on this table. 主键设置使查询在此表上运行得更快。 It also allows you to do several things with the table which you'd otherwise be posting question on here to figure out why they don't work. 它还允许您使用表格执行几项操作,否则您将在此处发布问题,以找出它们无法正常工作的原因。

The auto increment setting will allow you to skip that field all together when creating new records. 自动增量设置允许您在创建新记录时一起跳过该字段。 This means you won't need to lookup the highest value and add one every time you want a new record. 这意味着您不需要查找最高值,并且每次需要新记录时都要添加一个值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM