0

Having a populated feature class in a geodatabase, a non-nullable field should be added (or a currently nullable field changed to non-nullable).

That current field has currently no null values so I thought it's a straight forward job. With SQL I would use something like:

ALTER TABLE FeatureClassX
        ADD Status INTEGER NOT NULL.
    DEFAULT 0

However, I can not change the properties (non-null) with ArcGIS Pro 2.3.x nor with ArcGIS for Desktop 10.x. Also, using the Add Field and Alter Field tools do not allow me to change this property. Most likely due to the lack of being able to set/config a default value in those tools.

The only workaround I can come up at this point is to create a new feature class with same fields and properties and then copy each record one by one from the original feature class to the new one.

It is not difficult to write a script to do the workaround but I would like to avoid it and hope that I just have missed something in ArcGIS Pro 2.3.x and/or ArcGIS for Desktop 10.x. I am looking for a built-in solution for either of the ESRI products (or using Python) since I am currently lucky to have both installed.


Edit 2019-07-17 0821: Alter Field tool added to non-working solutions after I have tried umbe1987's answer

2

Found a solution: Error: Failed to add one of the specified fields. The field is not nullable

Works with ArcGIS for Desktop and ArcGIS Pro.


Summary

  1. Create a New Feature Class
    • on the last wizard screen, import field properties from existing table
    • then change Allow NULL values to yes and set a default value for the desired field
  2. Use Simple Data Loader to load data (or Append tool in ArcGIS Pro) from the old feature class
1

UPDATE - UNFORTUNATELY THIS DOES NOT WORK IF THE FEATURE CLASS IS NOT EMPTY

I guess you can try the Alter Field geoprocessing tool. It has a parameter field_is_nullable which you can set to NON_NULLABLE. This should do the trick.

  • Thank you. Yeah I have seen that but "this option is only applicable if the input table is empty" – Thomas Zuberbühler Jul 17 at 10:57
  • 1
    You're totally right, I thought the same but I did not find it in the help. Now I can see it... – umbe1987 Jul 17 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.