3

I'm looking at the syntax of SQL, specifically the character string literal.

<character string literal> ::=
    [ <introducer> <character set specification> ]
    <quote> [ <character representation> ... ] <quote>
    [ { <separator> <quote> [ <character representation> ... ] <quote> }... ]

Ignoring the [ <introducer> <character set specification> ] part, does this mean one or more <quote> [ <character representation> ... ] <quote>s separated by a <separator>?

If so, does that mean that 'hello' 'world' should be parsed as one <character string literal>?

For the query SELECT 'hello' 'world', Microsoft SQL Server 2005 returns:

+-------+
| world |
+-------+
| hello |
+-------+

and MySQL 5.0 returns:

+------------+
| hello      |
+------------+
| helloworld |
+------------+

I understand that every flavor of SQL is different, and that they don't all follow the standard. I'm just trying to determine whether I'm interpreting the BNF correctly. Thanks.

4

3 に答える 3

2

If so, does that mean that 'hello' 'world' should be parsed as one ?

According to ANSI SQL, yes.

于 2010-10-26T22:38:07.453 に答える
0

のBNFを見てください<separator> ::=

于 2010-10-26T19:13:11.773 に答える
0

SQL Serverで何が起こっているかを明確にするために、実際に行っているのは、列名が「world」の「hello」を返すことです。あなたの例は次のものと同じです:

SELECT 'hello' AS 'world'

考えをさらに広げようとすると、エラーが発生します。

SELECT 'hello' 'world' 'now'

Line 1: Incorrect syntax near 'now'.
于 2010-10-26T19:09:21.253 に答える