如果不存在则创建表返回“表不存在”

时间:2022-05-18 08:46:24

I have a problem in mysql, i try to run this sentence

我在mysql中有问题,我尝试运行这句话

CREATE TABLE IF NOT EXISTS comunidad_estado (
  id_comunidad_estado int(11) NOT NULL,
  nombre varchar(50) NOT NULL,
  id_pais int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=56 DEFAULT CHARSET=latin1;

and the return is this:

而且回报是这样的:

如果不存在则创建表返回“表不存在”

I know my db is empty but i can´t understand why does not it create the table

我知道我的数据库是空的,但我不明白它为什么不创建表

如果不存在则创建表返回“表不存在”

Thanks in advance.

提前致谢。

2 个解决方案

#1


It seems, schema / database is corrupted / locked.

看来,架构/数据库已损坏/锁定。

Possible solutions:

  • Restart mysql service and try again (Sometime lock applies to schema, and somehow doesn't unlock)
  • 重新启动mysql服务并重试(Sometime lock适用于架构,并以某种方式解锁)

  • Drop this schema, create new schema and try again (Sometime, on creation of schema - it get corrupted)
  • 删除此架构,创建新架构并重试(有时,在创建架构时 - 它会被破坏)

  • Repair mysql (mysqlcheck --repair) - to fix corrupted schemas.
  • 修复mysql(mysqlcheck --repair) - 修复损坏的模式。

  • Last, check permission.
  • 最后,检查权限。

To confirm your script, try @ http://sqlfiddle.com/ . If it works, then above possible reasons with your schema / database.

要确认您的脚本,请尝试@ http://sqlfiddle.com/。如果它有效,那么您的架构/数据库可能会出现上述原因。

#2


If anyone has the same mistake I solved it by changed the name of the query and then rename de db, a really weird work but It´s working. Thanks to Anil for the reference: Table doesn't exist after CREATE TABLE

如果有人有同样的错误我通过更改查询的名称解决它,然后重命名de db,这是一个非常奇怪的工作,但它正在工作。感谢Anil的参考:在CREATE TABLE之后表不存在

#1


It seems, schema / database is corrupted / locked.

看来,架构/数据库已损坏/锁定。

Possible solutions:

  • Restart mysql service and try again (Sometime lock applies to schema, and somehow doesn't unlock)
  • 重新启动mysql服务并重试(Sometime lock适用于架构,并以某种方式解锁)

  • Drop this schema, create new schema and try again (Sometime, on creation of schema - it get corrupted)
  • 删除此架构,创建新架构并重试(有时,在创建架构时 - 它会被破坏)

  • Repair mysql (mysqlcheck --repair) - to fix corrupted schemas.
  • 修复mysql(mysqlcheck --repair) - 修复损坏的模式。

  • Last, check permission.
  • 最后,检查权限。

To confirm your script, try @ http://sqlfiddle.com/ . If it works, then above possible reasons with your schema / database.

要确认您的脚本,请尝试@ http://sqlfiddle.com/。如果它有效,那么您的架构/数据库可能会出现上述原因。

#2


If anyone has the same mistake I solved it by changed the name of the query and then rename de db, a really weird work but It´s working. Thanks to Anil for the reference: Table doesn't exist after CREATE TABLE

如果有人有同样的错误我通过更改查询的名称解决它,然后重命名de db,这是一个非常奇怪的工作,但它正在工作。感谢Anil的参考:在CREATE TABLE之后表不存在