{"id":27772,"date":"2025-05-05T14:09:15","date_gmt":"2025-05-05T14:09:15","guid":{"rendered":"http:\/\/www.withdata.com\/blog\/?p=27772"},"modified":"2026-03-07T01:59:39","modified_gmt":"2026-03-07T01:59:39","slug":"store-rtf-in-oracle-clob","status":"publish","type":"post","link":"https:\/\/www.withdata.com\/blog\/clob\/store-rtf-in-oracle-clob.html","title":{"rendered":"Store RTF in Oracle CLOB"},"content":{"rendered":"<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Rich_Text_Format\">RTF<\/a>(Rich Text Format) can be stored as Oracle CLOB data.<\/p>\n<h2>1. Oracle CLOB Type Overview<\/h2>\n<p>Oracle CLOB (Character Large Object) is a native large character field supporting up to 4GB, designed for large text data.<\/p>\n<p>Requires initialization with EMPTY_CLOB() before writing large content via PL\/SQL.<\/p>\n<h2>2. Pure SQL\/PLSQL Implementation Steps<\/h2>\n<h3>Step 1: Create Table with CLOB Field<\/h3>\n<pre>CREATE TABLE RTF_DOCS (\r\n    DOC_ID NUMBER PRIMARY KEY,\r\n    DOC_NAME VARCHAR2(100) NOT NULL,\r\n    RTF_CONTENT CLOB NOT NULL,\r\n    CREATE_TIME DATE DEFAULT SYSDATE\r\n);\r\n<\/pre>\n<h3>Step 2: Insert RTF Text into CLOB Field<\/h3>\n<pre>-- Method 1: Insert short RTF text directly\r\nINSERT INTO RTF_DOCS (DOC_ID, DOC_NAME, RTF_CONTENT)\r\nVALUES (\r\n    1,\r\n    'test.rtf',\r\n    '{\\\\rtf1\\\\ansi\\\\deff0 {\\\\fonttbl {\\\\f0 Calibri;}} \\\\pard\\\\f0\\\\fs22 Oracle RTF Test\\\\par}'\r\n);\r\nCOMMIT;\r\n\r\n-- Method 2: Insert large RTF text with PL\/SQL (recommended)\r\nDECLARE\r\n    v_clob CLOB;\r\nBEGIN\r\n    -- Initialize CLOB\r\n    INSERT INTO RTF_DOCS (DOC_ID, DOC_NAME, RTF_CONTENT)\r\n    VALUES (2, 'large.rtf', EMPTY_CLOB())\r\n    RETURNING RTF_CONTENT INTO v_clob;\r\n    \r\n    -- Write RTF content (supports concatenating long text)\r\n    DBMS_LOB.WRITEAPPEND(v_clob, LENGTH('{\\\\rtf1\\\\ansi\\\\deff0 {\\\\fonttbl {\\\\f0 Arial;}} '), '{\\\\rtf1\\\\ansi\\\\deff0 {\\\\fonttbl {\\\\f0 Arial;}} ');\r\n    DBMS_LOB.WRITEAPPEND(v_clob, LENGTH('\\\\pard\\\\f0\\\\fs24 Large RTF Content in Oracle CLOB\\\\par}'), '\\\\pard\\\\f0\\\\fs24 Large RTF Content in Oracle CLOB\\\\par}');\r\n    \r\n    COMMIT;\r\nEND;\r\n\/\r\n<\/pre>\n<h3>Step 3: Query\/Edit RTF in CLOB<\/h3>\n<pre>-- Query full RTF content\r\nSELECT DOC_NAME, RTF_CONTENT FROM RTF_DOCS WHERE DOC_ID = 1;\r\n\r\n-- Truncate RTF preview (first 200 characters)\r\nSELECT DOC_NAME, DBMS_LOB.SUBSTR(RTF_CONTENT, 200, 1) AS RTF_PREVIEW FROM RTF_DOCS;\r\n\r\n-- Update CLOB content\r\nUPDATE RTF_DOCS \r\nSET RTF_CONTENT = '{\\\\rtf1\\\\ansi\\\\deff0 \\\\pard\\\\f0\\\\fs26 Updated Oracle RTF\\\\par}'\r\nWHERE DOC_ID = 1;\r\nCOMMIT;\r\n<\/pre>\n<h3>Step 4: Delete RTF Record<\/h3>\n<pre>DELETE FROM RTF_DOCS WHERE DOC_ID = 2;\r\nCOMMIT;\r\n<\/pre>\n<h2>3. Simplify Oracle CLOB RTF Management with DBBlobEditor<\/h2>\n<p>DBBlobEditor eliminates the need for complex PL\/SQL scripts for Oracle CLOB RTF management:<\/p>\n<ul>\n<li>\n<h3>View \/ Edit RTF<\/h3>\n<p><a href=\"\/blog\/oralobeditor\/view-rtf-data-in-oracle-clob-read-display-rtf-from-oracle-clob-column.html\">Visually browse and edit RTF content in Oracle CLOB fields<\/a> without command-line tools.<a rel=\"noopener\" href=\"\/images\/lobeditor\/blob-rtf.png\" target=\"_blank\">?<\/a><\/li>\n<li>\n<h3>Insert RTF into Oracle CLOB<\/h3>\n<p><a href=\"\/blog\/oralobeditor\/import-rtf-to-oracle-clob.html\">Bulk import RTF into Oracle CLOB<\/a> with few clicks.<\/li>\n<li>\n<h3>Extract Oracle CLOB to RTF<\/h3>\n<p><a href=\"\/blog\/oralobeditor\/oracle-export-clob-to-rtf.html\">Bulk export Oracle CLOB to RTF files<\/a> visually, avoiding complex scripts.<\/li>\n<\/ul>\n<h2>4. Notes<\/h2>\n<ul>\n<li>Oracle requires PL\/SQL + DBMS_LOB package for large CLOB inserts; direct INSERT of long text triggers character length limits<\/li>\n<li>Use DBMS_LOB.SUBSTR() instead of regular SUBSTR() for CLOB queries to avoid truncation<\/li>\n<li>Import external RTF files to CLOB with DBMS_LOB.LOADFROMFILE() (requires directory permissions)<\/li>\n<\/ul>\n<hr \/>\n<h3>Related Guides<\/h3>\n<ul>\n<li><a href=\"\/blog\/clob\/store-rtf-in-clob.html\">Store RTF in CLOB: Complete Guide for Character Fields Across Databases<\/a><\/li>\n<li><a href=\"\/blog\/clob\/store-rtf-in-db2-clob.html\">Store RTF in DB2 CLOB<\/a><\/li>\n<li><a href=\"\/blog\/clob\/store-rtf-in-sql-server-nvarcharmax.html\">Store RTF in SQL Server NVARCHAR(MAX)<\/a><\/li>\n<li><a href=\"\/blog\/clob\/store-rtf-in-mysql-text.html\">Store RTF in MySQL TEXT<\/a><\/li>\n<li><a href=\"\/blog\/clob\/store-rtf-in-postgresql-text.html\">Store RTF in PostgreSQL TEXT<\/a><\/li>\n<li><a href=\"\/blog\/clob\/store-rtf-in-sqlite-text.html\">Store RTF in SQLite TEXT<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>RTF(Rich Text Format) can be stored as Oracle CLOB data. 1. Oracle CLOB Type Overview Oracle CLOB (Character Large Object) is a native large character field supporting up to 4GB, designed for large text data. Requires initialization with EMPTY_CLOB() before writing large content via PL\/SQL. 2. Pure SQL\/PLSQL Implementation Steps Step 1: Create Table with [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4526],"tags":[100,1325,2106],"class_list":["post-27772","post","type-post","status-publish","format-standard","hentry","category-clob","tag-clob","tag-oracle","tag-rtf"],"_links":{"self":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/27772","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/comments?post=27772"}],"version-history":[{"count":5,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/27772\/revisions"}],"predecessor-version":[{"id":45452,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/27772\/revisions\/45452"}],"wp:attachment":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/media?parent=27772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/categories?post=27772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/tags?post=27772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}