Oracle错误,未在预期的位置找到FROM关键字

时间:2018-10-17 21:00:21

标签: sql oracle ora-00923

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

  

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) 

1 个答案:

答案 0 :(得分:5)

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

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>

我删除了最后一个“条件”(无论如何都无效,但没有引起该问题)。