Long-term use of commonly prescribed heartburn drugs increases the likelihood of someone being deficient in a vital B vitamin, a study has shown.

Lack of vitamin B12 can raise the risk of dementia, nerve damage, anaemia and other conditions, some of which may be irreversible.

Scientists who studied US patients found an association between taking some antacid medications and diagnosed vitamin B12 deficiency.

Stomach acids are known to aid vitamin B12 absorption. Suppressing the acids, to combat heartburn and acid reflux, or treat ulcers, may lead to a health-threatening lack of the vitamin in the body, scientists think.

The study is the first large population-based investigation linking vitamin B12 deficiency to antacid drugs known as protein pump inhibitors (PPIs), which is commonly prescribed.

Examples of PPIs include the drugs esomeprazole, lansoprazole, omeprazole, pantoprazole and rabeprazole.

"Patients who took PPI medications for more than two years had a 65% increase in their risk of B12 deficiency," said study leader Dr Douglas Corley, a gastroenterologist with the Kaiser Permanente Division of Research. "Higher doses also were associated with an increased risk, compared with lower doses."