Oracle 数据库执行 select table_name,wm_concat(colum_name) as colum_name from all_tab_colums a group by a.table_name order by colum_name 语句报错提示 ORA-00932: inconsistent datatypes: expected- got CLOB
时间: 2024-03-09 12:49:05 浏览: 136
向Oracle数据库的CLOB属性插入数据报字符串过长错误
5星 · 资源好评率100%
The reason you are getting the ORA-00932 error is because `wm_concat` returns a CLOB data type, which cannot be used in the `ORDER BY` clause. To fix this error, you can use the `DBMS_LOB.SUBSTR` function to convert the CLOB data type to a VARCHAR2 data type. Here is an updated version of your SQL query:
```
SELECT table_name, DBMS_LOB.SUBSTR(wm_concat(column_name), 4000) AS column_name
FROM all_tab_columns
GROUP BY table_name
ORDER BY column_name;
```
Note that the second parameter of `DBMS_LOB.SUBSTR` specifies the maximum length of the output string, so you can adjust it based on your needs.
阅读全文