简体   繁体   English

表不可编辑的mysql工作台错误

[英]table not editable mysql workbench error

I have a table that has no primary key. 我有一个没有主键的表。 All I want to do is see the data. 我要做的就是查看数据。 I DO NOT WANT TO EDIT IT. 我不想编辑它。 Yet, whenever I run this query... 但是,每当我运行此查询...

SELECT * FROM TableThatHasNoPrimaryKey  

MySQL Workbench (version 5.2.36 v8542, running on Ubuntu 10.04 64 bit) gives me this error... MySQL Workbench(版本5.2.36 v8542,在Ubuntu 10.04 64位上运行)给我这个错误...

table data is not editable because there is no primary key defined for the table

Is this a bug? 这是错误吗? This query displays the data just fine on MySQL browser. 该查询显示的数据恰好在MySQL浏览器上。

SELECT * FROM(SELECT * FROM TableWithNoPrimaryKey)AS tmp

Another workaround 另一个解决方法

select *, char_length('') from tableName

Using a function in the select statement gets around the issue 在select语句中使用函数可以解决问题

I found this on internet: 我在互联网上找到了这个:

try this launch the workbench using: 尝试使用以下命令启动工作台:

"mysql-workbench --log-level=debug3"

it's a bug, take a look here: 这是一个错误,请在此处查看:

http://bugs.mysql.com/bug.php?id=62893 http://bugs.mysql.com/bug.php?id=62893

if not you will have to add a primary key, take a look to this forum 如果不是的话,您将不得不添加一个主键,看看这个论坛

MYSQL and python error MYSQL和Python错误

I use this as a workaround: 我将其用作解决方法:

DROP TEMPORARY TABLE IF EXISTS TempTableThatHasNoPrimaryKey;

CREATE TEMPORARY TABLE TempTableThatHasNoPrimaryKey
SELECT *
FROM TableThatHasNoPrimaryKey;

SELECT * FROM TempTableThatHasNoPrimaryKey

for some strange reason this works... 由于某些奇怪的原因,这可行...

要在mysql工作台中以编辑模式打开表,您需要在表中有一个主键列,否则它始终只能以读取模式打开。

如果只需要从表中获取数据,则可以为此创建Views

重新启动工作台为我修复了它。

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

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