Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Teams
, (opens new window)

SQL for Confluence
Results will update as you type.
  • Get started
  • Data Center 11.x
    • Help and support - 11.x
      • Troubleshoot Data Source Profiles - 11.x
      • Troubleshoot Application Server Based Data Sources - 11.x
      • Sample queries - Confluence labels
      • SQL for Confluence Announcement and FAQ
    • Use cases - 11.x
    • Macro Reference - 11.x
    • Key Concepts - 11.x
    • Overview - Data Center 11.x
    • Installation and configuration - Data Center
  • Cloud
  • Release notes
  • Help and support
    You‘re viewing this with anonymous access, so some content might be blocked.
    /
    Sample queries - Confluence labels
    Updated Aug 11

    Sample queries - Confluence labels

    These queries works with PostgreSQL and were tested against Confluence 5.10. You may need to adjust slightly for other databases. As with all queries against a product database, you need to define a new read-only data source to access the product's database.

    Thanks to Shiran Kleiderman for the initial query and question on extending.

    Site labels

    select name as "Label" , count(name) as "Count" from CONTENT_LABEL left join LABEL on CONTENT_LABEL.labelid = LABEL.labelid group by name order by name

    Labels for space

    select name as "Label" , count(name) as "Count" from CONTENT_LABEL left join LABEL on CONTENT_LABEL.labelid = LABEL.labelid left join CONTENT on CONTENT_LABEL.contentid = CONTENT.contentid left join SPACES on CONTENT.spaceid = SPACES.spaceid where spacekey in ('ds') group by name order by name

    Labels by space

    select spacename as "Space" , name as "Label" , count(name) as Count from CONTENT_LABEL left join LABEL on CONTENT_LABEL.labelid = LABEL.labelid left join CONTENT on CONTENT_LABEL.contentid = CONTENT.contentid left join SPACES on CONTENT.spaceid = SPACES.spaceid group by spacename, name order by spacename, name

    Need support? Create a request with our support team.

    Copyright © 2005 - 2025 Appfire | All rights reserved.

    {"serverDuration": 15, "requestCorrelationId": "1bdb9cd0f7dd408bbf6fa5143ee43a96"}