简体   繁体   English

我的 SQL Fiddle 查询有什么问题?

[英]What's wrong with my SQL Fiddle query?

Take a look at this simple query in SQL fiddle: http://sqlfiddle.com/#!2/c1eb6/1 .看看 SQL fiddle 中的这个简单查询: http ://sqlfiddle.com/#!2/c1eb6/1。 This is a super-simple update query, why is it producing an error?这是一个超级简单的更新查询,为什么会产生错误? I wonder if could it be a bug in that site?我想知道这是否可能是该网站中的错误?

Build Schema:构建架构:

create table your_table (some_column varchar(50));

insert into your_table set some_column = '30# 11';
insert into your_table set some_column = '30# 12.00';
insert into your_table set some_column = '30# 13.5';
insert into your_table set some_column = 'abdfs';
insert into your_table set some_column = '0000000';

Query:询问:

UPDATE your_table
SET some_column = 1;

A bit of background for those interested in some of the arcane issues I've been dealing with on SQL Fiddle:对于那些对我在 SQL Fiddle 上处理的一些神秘问题感兴趣的人来说一些背景知识:

Disable explicit commits in JDBC, detect them in SQL, or put the database in a readonly state (dba.se)在 JDBC 中禁用显式提交,在 SQL 中检测它们,或将数据库置于只读状态(dba.se)

Essentially, I am trying to ensure that the fiddles always remain in a consistent state, even as people play with them.从本质上讲,我试图确保小提琴始终保持一致的状态,即使人们在玩它们。 One thing I've worried about is people intentionally messing with the databases, breaking them for the other people that might be working with them (this has happened before, but not often fortunately).我担心的一件事是人们故意弄乱数据库,为可能正在使用它们的其他人破坏它们(这种情况以前发生过,但幸运的是不经常发生)。

I've found methods of keeping things clean for each of the database platforms, but interestingly each method is completely different for each platform.我已经找到了为每个数据库平台保持清洁的方法,但有趣的是,每个平台的每个方法都完全不同。 Unfortunately, for MySQL I had to resort to the worst option - only allowing SELECTs on the right-hand side.不幸的是,对于 MySQL,我不得不求助于最糟糕的选择——只允许右侧的 SELECT。 This is because there are too many ways to write queries that include implicit commits, and there is no way that I've found to prevent that from happening short of outright denial on the query side.这是因为有太多方法可以编写包含隐式提交的查询,而且我发现没有办法阻止这种情况发生,除非在查询端完全拒绝。 This is quite unfortunate, I realize, but it seems to be required.这很不幸,我意识到,但这似乎是必需的。

Anyhow, this particular bug was a result from a change I had recently made in the logic for MySQL.无论如何,这个特殊的错误是我最近对 ​​MySQL 逻辑所做的更改的结果。 It is fixed now, and now reports the expected error message:现在已修复,现在报告预期的错误消息:

DDL and DML statements are not allowed in the query panel for MySQL; MySQL 的查询面板中不允许使用 DDL 和 DML 语句; only SELECT statements are allowed.只允许 SELECT 语句。 Put DDL and DML in the schema panel.将 DDL 和 DML 放在架构面板中。

我在 SQL Fiddle 上收到此错误,因为我试图使用 PostgresSql 语法,而解释器设置为 MySql

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

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