Updating Labels in Jira Server and Data Center using SQL

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

For some reason, there are labels on my Jira environment that includes spaces.

I need to remove the space in bulk because it is causing issues on my Jira environment when I try to migrate issues to another Jira environment.

Environment

9.4.14 → 9.12.2

Solution

Before you Begin:

Always back up your data before making any database modifications. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

Steps to Check, and Update, Labels in Jira using SQL

  • Determine impacted labels

1 SELECT * FROM "label" where "label" like '% %';
  • Then, Stop Jira

  • Next, Update the labels

1 UPDATE "label" SET "label" = replace("label",' ','_') where "label" like '% %';

⚠️ The query was ran and tested on Postgres 14 and might need to be updated by your DBA to reflect your specific database.

  • Finally, start Jira

Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.