简体   繁体   English

(MySQL)以某种方式命名了一个数据库默认值并且根本无法使用它,因为 MySQL 工作台认为我使用默认数据tyoe

[英](MySQL) named a database default somehow and cant work with it at all because MySQL workbench thinks im using the default data tyoe

Basically what it sounds like the database is named default基本上听起来像数据库被命名为默认

which was already there when i made the connection and the tables that are in it are inaccesible.当我建立连接时它已经存在并且其中的表格无法访问。

I've tried moving the tables to another database but mysql doesnt recognize that when i type default i mean the database and not the data type in mysql.我尝试将表移动到另一个数据库,但 mysql 没有认识到当我输入默认值时,我的意思是数据库而不是 mysql 中的数据类型。

Any help?有什么帮助吗? I goofed somehow and dont know how to fix it and havent found anything else like this problem online.我不知何故搞砸了,不知道如何解决它,也没有在网上找到类似这个问题的其他任何东西。

You can use any SQL reserved keyword as an identifier, but you must enclose them in back-ticks:您可以使用任何SQL 保留关键字作为标识符,但必须将它们括在反引号中:

SELECT ... FROM `default`.admin ...

It's simpler if you move the tables to another schema that has a name that doesn't conflict with a reserved keyword.如果您将表移动到另一个名称与保留关键字不冲突的模式,则会更简单。

Unfortunately, there's no RENAME SCHEMA statement in MySQL.不幸的是,MySQL 中没有 RENAME SCHEMA 语句。 You have to create a new schema and then RENAME TABLE to move them one by one.您必须创建一个新架构,然后重命名 TABLE 才能将它们一一移动。

CREATE SCHEMA my_awesome_schema;

RENAME TABLE `default`.admin TO my_awesome_schema.admin;
...same for other tables...

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

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