我看过一些关于关键字区分大小写的文章,但我对某些事情有点困惑,不想死帖我决定在这里发布。
我正在使用 SQL Server Management Studio,并且看到如下 SQL 代码:
SELECT * from custTable as A
INNER JOIN custTable as a
ON A.custID = a.custID
然后我也看到了这样的 SQL 代码
SELECT A.CustID FROM custTable A
INNER JOIN
(SELECT a.CustID FROM custTable a
JOIN
(SELECT A.CustID FROM custTable A
JOIN
(SELECT CustID FROM custTable
WHERE [CustID] = 1
GROUP BY [CustID] ) ap ON A.CustID = ap.CustID
GROUP BY A.[CustID] ) m ON A.CustID = m.CustID ) AP ON ap.CustID = A.CustID
显然,SQL 代码在别名方面是区分大小写的。但是,已经看到与上面类似的代码是这样写的:
SELECT A.CustID FROM custtable A
INNER JOIN
(SELECT a.CustID FROM CustTable a
JOIN
(SELECT A.CustID FROM CUSTTABLE A
JOIN
(SELECT CustID FROM Custtable
WHERE [CustID] = 1
GROUP BY [CustID] ) ap ON A.CustID = ap.CustID
GROUP BY A.[CustID] ) m ON A.CustID = m.CustID ) AP ON ap.CustID = A.CustID
显然,SQL 代码在表名方面被认为是不区分大小写的。
这是因为表名基本上是字符串常量,而别名就像局部变量吗?