0

我试图弄清楚为什么我会收到此错误消息。我尝试以各种方式修改代码,但仍然收到错误消息。下面列出了错误消息。

ORA-00923 : 在预期的地方找不到 FROM 关键字

 SELECT 'DATABASE' as DATABASE,
         OWNER AS SCHEMA, 
         TABLE_NAME AS TABLE, 
         COLUMN_NAME AS COLUMN
   FROM ALL_TAB_COLUMNS 
  WHERE OWNER = 'ALSCMGR' 
    AND TABLE_NAME IN ('ALSC_TRANS_NONMONETARY')
    AND UPPER(COLUMN_NAME) 
4

1 回答 1

5

您不能使用TABLE也不COLUMN作为列别名;将它们重命名为其他名称,例如

SQL> SELECT
  2    'DATABASE'  as DATABASE,
  3    OWNER       AS SCHEMA,
  4    TABLE_NAME  AS TABLE_n,
  5    COLUMN_NAME AS COLUMN_n
  6  FROM
  7    ALL_TAB_COLUMNS
  8  WHERE
  9      OWNER = 'ALSCMGR' AND
 10      TABLE_NAME IN('ALSC_TRANS_NONMONETARY')
 11  --and UPPER(COLUMN_NAME) ;

no rows selected

SQL>

或者,将别名括在双引号中:

SQL> SELECT
  2    'DATABASE'  as DATABASE,
  3    OWNER       AS SCHEMA,
  4    TABLE_NAME  AS "TABLE",
  5    COLUMN_NAME AS "COLUMN"
  6  FROM
  7    ALL_TAB_COLUMNS
  8  WHERE
  9      OWNER = 'ALSCMGR' AND
 10      TABLE_NAME IN('ALSC_TRANS_NONMONETARY')
 11  --and UPPER(COLUMN_NAME) ;

no rows selected

SQL>

我已经删除了最后一个“条件”(无论如何这都是无效的,但没有导致那个问题)。

于 2018-10-17T21:04:10.043 回答