which database table holds custom fields information?

srikanth_ccx January 4, 2017
 

1 answer

1 accepted

5 votes
Answer accepted
Mike Rathwell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 4, 2017

Curiously, I am mucking about with this very thing right now. The tables you want will be:

  • customfield - Contains the definition of the fields
  • customfieldoption - Contains any defaults or other information that might be set in the field
  • customfieldvalue - Contains the actual values held by the fields.

IF you are going to modify this outside JIRA, you'll want to stop the instance, do the mods and make sure you set unique id values larger than what is in there and then update the sequence table. This link is of great help for that: https://developer.atlassian.com/jiradev/jira-platform/jira-architecture/database-schema#Databaseschema-Customfields

Good luck

 

srikanth_ccx January 4, 2017

Hi Mike,

 

Thanks for the response.

Please find custom fields and  ID's and project ID below.

 

custom field 1: Percent QA Testing Completed

fieldId=customfield_10502

 

custom field 2: Percent UAT Testing Completed

fieldId=customfield_10503

 

Project ID: EditIssueType!default.jspa?id=10104

 

Project Key=DA

I ran below query and result came out no search is found.

 

select * from [jiraschema].[customfieldvalue]

where issue=(select id from [jiraschema].jiraissue

   where project = (SELECT id from [jiraschema].project

   where pkey='10502') AND issuenum = '10503');

 

 

I want those customfield tables in database. please let me know how can i find it out.

 

Thanks,

srikanth 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 4, 2017

Please, avoid touching the database, it's a pain to use for reporting/lookups, and there are no circumstances under which it's a good idea to write to it (beyond bug fixes).

But, if you must.

I don't understand what your query is trying to do, it looks very very confused.  You appear to be using custom field IDs to read the issue for a start, which is complete nonsense.

I am going to guess that you want the value of the custom fields named "Parent QA/UAT testing complete", AND that those fields are simple text or numeric fields.

First, read the project table for the project key

select id from project where key = 'DA' ;

Then you can get the values for both custom fields by using

select * from customfieldvalue
join jiraissue on customfield.issue = jiraissue.id
where jiraissue.pkey = <project id from above> and
customfield in ( 10502, 10503 ) ;


I've kept the SQL long winded and probably inefficient, but easier to read and understand how the tables relate.

If the fields are select type fields, you'll need to do more work to get the actual values out.

Like # people like this
VR August 25, 2021

I have been reviewing these tables and unable to get the entries that does not have a value for a custom field. 

 

For Instance, customfield 10502 is not a required field and there are lot of JIRA issue with/without values for this custom field. I could query to get the list of issues with entries but unable to get the list which does not have an entry.

select * from customfieldvalue where CUSTOMFIELD = 10502 and STRINGVALUE is null;  - Doesn't fetch anything

 

cf[10502] is empty - as JQL works.

 

Can you please help @Nic Brough -Adaptavist- 

Thanks,

Vignesh

VR August 25, 2021

For instance, this query gets a list of all epics which has entries for customfield_1, customfield_2, customfield_3)

Works

select jp.pkey||'-'||ji.issuenum as issuekey,jp.pname as proj, ji.Summary, issuestat.pname, cf.cfname, cfv.stringvalue
from project jp, jiraissue ji, issuestatus issuestat, customfield cf, customfieldvalue cfv
where jp.id = ji.project and cf.cfname IN ( 'customfield_1, 'customfield_2','customfield_3') 
and ji.issuestatus = issuestat.id
and cfv.issue = ji.id
and cf.id = cfv.customfield
and JI.issuetype = '10000'
order by jp.pkey, ji.issuenum;

 

Doesn't fetch empty values/null

select jp.pkey||'-'||ji.issuenum as issuekey,jp.pname as proj, ji.Summary, issuestat.pname, cf.cfname, cfv.stringvalue
from project jp, jiraissue ji, issuestatus issuestat, customfield cf, customfieldvalue cfv
where jp.id = ji.project and cf.cfname IN ( 'customfield_1, 'customfield_2','customfield_3') and cfv.STRINGVALUE is null
and ji.issuestatus = issuestat.id
and cfv.issue = ji.id
and cf.id = cfv.customfield
and JI.issuetype = '10000'
order by jp.pkey, ji.issuenum;

 

Tried with JOIN queries too but doesn't fetch empty values for these custom field. @Nic Brough -Adaptavist- Not sure, what I'm missing.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 25, 2021

Yes, this is exactly one of the reasons you should not be looking in the database.

Empty fields do not have any data, and you can't use SQL to find something that is not there.

You can find them with JQL, and all the functions in the UI and REST, because it understands the database via its code.  You can't find them with SQL because it can't find them, it doesn't understand the data.

Like VR likes this
VR August 25, 2021

Thank you so much for the immediate response @Nic Brough -Adaptavist- That helps.

Suggest an answer

Log in or Sign up to answer