According to WMO

A code table is a list of choices where only one of the choices can be selected at a given time. The selection is accomplished by coding the number of the desired entry in the appropriate place in the GRIB2 Section. A flag table, on the other hand, is a list of choices where any combination of the choices can be selected at a given time. The combination is accomplished by turning bits of a bit string on or off. Code and Flag tables are also categorised by the Section number in which the code or flag table is referred to.

This applies equally well to GRIB1 and also to BUFR.

For example if you do a grib_dump -O -t on a GRIB2 file, you will see some keys whose type is Code Table ("codetable") and Flag Table ("codeflag"):

% grib_dump -O -t samples/GRIB2.tmpl
15 codetable (int) shapeOfTheEarth = 0 [Earth assumed spherical with radius = 6,367,470.0 m (grib2/tables/4/3.2.table) ]
55 codeflag (int) resolutionAndComponentFlags = 48 [00110000 (grib2/tables/4/3.3.table) ]

Here the shapeOfTheEarth key has type "codetable" so its values come from the entries in Code Table 3.2. The path of the table file relative to the definitions directory is also shown (grib2/tables/4/3.2.table).
And the other key resolutionAndComponentFlags has the type "codeflag" with Flag Table 3.3. We can see which bits of the integer have been set: the 3rd and 4th bits are set and the rest are zero (reading from left to right; most significant bit to least significant). To see the full meaning of those bits, you will need to use the "-D" option of grib_dump:

% grib_dump -Dt samples/GRIB2.tmpl
91-92 codeflag resolutionAndComponentFlags = 48 [00110000:
      (3=1)  i direction increments given;
      (4=1)  j direction increments given;
      (5=0)  Resolved u- and v- components of vector quantities relative to easterly and northerly directions:

The "(3=1)" part means the 3rd bit is set and that means "i direction increments given", similarly the 4th bit is set and that means "j direction increments given" and so on. Note that the other bits (1, 2, 6 and 8) are reserved so there is no meaning associated with them.

Note: The content of Flag Table keys should not be interpreted as a value, for that is meaningless in this case. Rather, the individual bits must be inspected. For this reason ecCodes has other keys which correspond to these bits: in the case of resolutionAndComponentFlags, we have the associated keys:


You can query these keys (to decode the flags) as well as set them (to encode the flags).