问题
I have a table with one column of CLOB type data, they are all very short no more than 20 bytes, however I cannot see the actual string in the CLOB data.
For example if I use SELECT *
, under the CLOB type every data is like:
CLOB, 8 Bytes
CLOB, 15 Bytes
CLOB, 9 Bytes
But I just want to see the content of the CLOB data.
I tried:
SELECT DBMS_LOB.SUBSTR(ClobColumnName, 20 ,1)
And it doesn't work, error is:
Error Code: 4121, SQL State: S1000
Cannot find either column "DBMS_LOB" or the user-defined function or aggregate "DBMS_LOB.SUBSTR", or the name is ambiguous.
So can I ask what's the syntax for direct display a CLOB data in a query?
I'm using SQL Server with dbVisualizer
.
回答1:
I figured out one solution. There should be better ways, please show more possible solutions in the comments.
SELECT CAST(ClobColumnName AS VARCHAR(50)) AS ClobColumnName ;
回答2:
I have table with one column has CLOB data type(1000K), after storing message/data into CLOB column and found one solution see the actual data in CLOB column.
SELECT CAST(T.CLOB_COLUMNNAME AS VARCHAR(1000)) AS SAMPLEDATA
FROM TABLE_NAME AS T
The above query CAST the CLOB(Character Large Objects) into a normal String.
回答3:
To see it in DbVis you just have to change it in the options. There is an entry for the display of CLOB columns.
回答4:
I presume you are using jDTS driver to connect to the SQL Server. In the driver properties of the connection you can set the "USELOBS" to False to automatically cast them to string.
回答5:
I had the same problem and solved it by using DBeaver (http://dbeaver.jkiss.org/) instead of dbVisualizer.
When I use DBeaver and do a select * from my SQLServer I can just double-click the CLOB in the result set and it opens in a new window with the content. Very slick.
来源:https://stackoverflow.com/questions/15377158/how-to-show-clob-type-in-a-select-in-sql-server