This may seem like an impertinent question but I really have done some googling to try to find the BNF or any rigorous documentation on column name syntax.
The reason I need rigor is that I have 700+ csv files that have names that I drew from patchworknation but they had all kinds of special characters and what not. Some are very long names. I intend on getting these things imported, one per column, in a huge R data file and want to keep the correspondence between the file names and the column names. So I've renamed them all to snake case, lower cased them and eliminated all of the characters outside of
[a-z0-9_]. That should be well within most sane constraints on names but I can't even be certain that the length of the names is ok -- and I'm a little nervous about underscore given this ancient query for help that no one answered.