This tip is very useful if you need to check the length of a CLOB column in an Oracle table since the normal length...
function does not work on a CLOB column. Many people write their own routines or use other lengthy methods to get the length of a CLOB column. This tip makes it easier. It has been tested on Oracle 8.1.7 on Sun Solaris.
You can get the length of CLOB column data for a particuler record directly by using the dbms_lob package provided by Oracle. For example, create a table called MYTAB with column col1 with datatype CLOB. Then insert one record into MYTAB. Now let's say that you want to know the length of col1 data. To get it, use the following query:
select dbms_lob.getlength(col1) from mytab;
For More Information
- Feedback: E-mail the editor with your thoughts about this tip.
- More tips: Hundreds of free Oracle tips and scripts.
- Tip contest: Have an Oracle tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize -- submit your tip today!
- Ask the Experts: Our SQL, database design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.
- Forums: Ask your technical Oracle questions--or help out your peers by answering them--in our active forums.
- Best Web Links: Oracle tips, tutorials, and scripts from around the Web.