技术开发 频道

专家点评:达梦6.0试用之SQL篇

  下面看看对其他Oracle特有的语法支持的如何:

SQL>SELECT *
2   FROM T, T1
3   WHERE T.ID = T1.ID;
SELECT *
FROM T, T1
WHERE T.ID = T1.ID;
id              name            create_date             ID
1       1       TEST    2010-03-31      1
1 rows got
time used:
0.521(ms) clock tick:855860.
SQL
>SELECT *
2   FROM T, T1
3   WHERE T.ID = T1.ID (+);
SELECT *
FROM T, T1
WHERE T.ID = T1.ID (+);
id              name            create_date             ID
1       1       TEST    2010-03-31      1
2       2       NEWNAME 2010-03-31      NULL
3       2       TEST    2010-03-31      NULL
3 rows got
time used:
36.644(ms) clock tick:61195700.

  不但普通的连接支持,连Oracle的外连接’+’都是支持的。

SQL>SELECT *
2   FROM
3   (
4       SELECT ROWNUM RN, A.*
5       FROM
6       (
7               SELECT T.*
8               FROM T, T1
9               WHERE T.ID = T1.ID(+)
10              ORDER BY 2, 1
11      ) A
12      WHERE ROWNUM <= 5
13  )
14  WHERE RN > 1;
SELECT *
FROM
(
        
SELECT ROWNUM RN, A.*
        
FROM
        (
                
SELECT T.*
                
FROM T, T1
                
WHERE T.ID = T1.ID(+)
                
ORDER BY 2, 1
        ) A
        
WHERE ROWNUM <= 5
)
WHERE RN > 1;
RN              id              name            create_date
1       2       1       TEST    2010-03-31
2       3       2       TEST    2010-03-31
2 rows got
time used:
30.910(ms) clock tick:51615050.

  Oracle的标准分页语句是支持的,查询子查询语句是支持的,ORDER BY常量代替列名也是支持的。

SQL>SELECT ROW_NUMBER() OVER(ORDER BY NAME, ID DESC) RN,
2   ID,
3   NAME
4   FROM T;
第1行:
'('附近有语法错误

  显然分析函数是不支持的,虽然分析函数在8i就出现了,不过确实属于Oracle比较特有的技术,达梦不支持分析函数并不意外。

SQL>SELECT NAME, MAX(ID)
2   FROM T
3   GROUP BY NAME
4   HAVING COUNT(*) > 1;
SELECT NAME, MAX(ID)
FROM T
GROUP BY NAME
HAVING COUNT(*) > 1;
NAME
1       TEST    2
1 rows got
time used:
0.583(ms) clock tick:963240.
SQL
>SELECT NAME, AVG(ID)
2   FROM T
3   GROUP BY ROLLUP(NAME);
SELECT NAME, AVG(ID)
FROM T
GROUP BY ROLLUP(NAME);
无效的存储过程名
'ROLLUP' .error code = -1024

  显然聚集函数、GROUP BY语句和HAVING语句都是支持的。但是8i开始Oracle对GROUP BY提供了ROLLUP和CUBE功能,而这显然是达梦所不支持的,既然ROLLUP和CUBE不支持,那么对应的GROUPING等CUBE和ROLLUP专用的函数肯定也是不支持的。

SQL>SELECT T.ID, T1.ID ID1
2   FROM T, T1
3   WHERE T.ID = T1.ID (+)
4   ORDER BY 2 NULLS FIRST;
第4行:
'NULLS'附近有语法错误

  支持ORDER BY语句,但是Oracle的NULLS LAST和NULLS FIRST语法并不支持。

SQL>SELECT ID, (SELECT ID FROM T1 WHERE T1.ID = T.ID)
2   FROM T;
SELECT ID, (SELECT ID FROM T1 WHERE T1.ID = T.ID)
FROM T;
ID
1       1       1
2       2       NULL
3       2       NULL
3 rows got
time used:
0.556(ms) clock tick:916730.
0
相关文章