1在SQL中是否总是等于1?

1在SQL中是否总是等于1?,第1张

1在SQL中是否总是等于1?

SELECT 1='1'
给人
TRUE
因为
'1'
是一个正确的构造函数
INT
中知道我所有的实现。

但是SQL使用严格的类型,请注意:

# SELECT 1=CAST('1' AS TEXT);ERROR:  operator does not exist: integer = textLINE 1: SELECT 1=CAST('1' AS TEXT);     ^HINT:  No operator matches the given name and argument type(s). You might need to add  explicit type casts.

关于标准(SQL 92、99和2003),这似乎是错误的:

     <literal> ::= <signed numeric literal>          | <general literal>     <general literal> ::= <character string literal>          | <national character string literal>          | <bit string literal>          | <hex string literal>          | <datetime literal>          | <interval literal>     <signed numeric literal> ::=          [ <sign> ] <unsigned numeric literal>     <unsigned numeric literal> ::= <exact numeric literal>          | <approximate numeric literal>     <exact numeric literal> ::= <unsigned integer> [ <period> [ <unsigned integer> ] ]          | <period> <unsigned integer>     <unsigned integer> ::= <digit>...     <character string literal> ::=          [ <introducer><character set specification> ]          <quote> [ <character representation>... ] <quote> [ { <separator>... <quote> [ <character representation>... ] <quote> }... ]

因为

<quote>
包含
<bit string literal>
,,
<hex string literal>
…中,但不包含在数字文字中。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5662365.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存