How to retrieve the Comments in Pages and Blog posts via SQL

Still need help?

The Atlassian Community is here for you.

Ask the community

Summary

Confluence considers Comment on pages and blog posts as content and it holds the metadata of the comments in the CONTENT table and the data itself in the BODYCONTENT table.

Solution

If you want to retrieve all the comments in your Confluence instance, you can use the following SELECT statement:

SELECT *
FROM BODYCONTENT
WHERE CONTENTID IN (
   SELECT CONTENTID
   FROM CONTENT
   WHERE CONTENTTYPE = 'COMMENT')


To fetch the comments of an individual page, you can use the following statement (replacing the <pageID> tags): 

SELECT *
FROM CONTENT C
INNER JOIN BODYCONTENT B ON C.CONTENTID = B.CONTENTID
WHERE
    C.CONTENTTYPE='COMMENT'
    AND PREVVER is null
    AND CONTENT_STATUS = 'current' and pageid=<pageID>


Related content:

Last modified on Aug 25, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.