如何编写一个短语法正确的查询,运行时生成错误? [英] How to write a short grammatically correct query that generates an error when run?

查看:97
本文介绍了如何编写一个短语法正确的查询,运行时生成错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个查询:


  • 尽可能短


我当前的解决方案是:

My current solution is:

CREATE TABLE FOO (i INT);
INSERT INTO FOO VALUES (1);
INSERT INTO FOO VALUES (2);
SELECT 1 FROM FOO WHERE 1 = (SELECT i FROM FOO);

但我不喜欢 - 太长了。

However I don't like it - it is too long.

推荐答案

以下是一些正确但会失败的简短查询。

Here are some short queries that are all "correct" but will fail

SELECT *

SELECT 1e333

SELECT i FROM(SELECT 1i,1i)

详细版本为

SELECT * FROM DUAL

SELECT 1e333 FROM DUAL

SELECT i FROM (SELECT 1 as i, 1 as i FROM DUAL)

他们因为不同的原因失败:

They fail for different reasons:

1)DUAL没有任何列。

1) DUAL does not have any columns.

2)1e333不适用于浮点型。

2) 1e333 does not fit into a float.

3)内部查询返回具有两个相同命名列的表。因此,指定此列名称对于外部查询是不允许的。

3) The inner query returns a table with two identical named columns. Thus specifying this column name is not admissible for the outer query.

这篇关于如何编写一个短语法正确的查询,运行时生成错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆