To treat a cavity the dentist will have to remove decayed part of the tooth and then fill the hollow are of the tooth. The dentist will clean the cavity of bacteria and debris.
In modern dentistry there are many types of materials used for fillings. Location and amount of the decay, the cost of material, insurance coverage and the dentist's recommendation contribute the type of filling that will be used.

Types of teeth fillings

Silver amalgam (which consists of copper, zinc, mercury mixed with silver and tin)
Tooth-colored, plastic and composite resin fillings.

Gold Advantages

Durability – can last 10 to 15 years, and more, doesn’t corrode. Strong. Some patients find gold more pleasing to the eye than amalgam fillings.

Gold Disadvantages

Expense, requires at least two office visits to place, most patients don’t find any “colored” fillings to be an “eye-pleasing” advantage.

Amalgam fillings advantages

Durability – can last 10 to 15 years. Strength – can withstand chewing forces. Less expensive than composite fillings.

Amalgam fillings disadvantages

Fillings don’t match the color of your natural teeth. Healthy parts of the tooth must often be removed to make a space to hold the amalgam filling. Amalgam fillings can create a grayish hue to the surrounding tooth structure. Amalgam fillings may experience a wider degree of expansion and contraction and lead to a higher incidence of cracks and fractures. Approximately 1%, of patients are allergic to the mercury present in amalgam fillings

Composite fillings advantages

Aesthetics – shade and color of composites can be matched to the color of existing teeth; is particularly well suited for visible parts of teeth. Composite fillings chemically bond to tooth structure, providing further support to the tooth. Composite fillings can also be used to repair chipped, broken or worn teeth.

Composite fillings disadvantages

Composite fillings wear out faster than other types of fillings. If composites are used for inlays or onlays, more than one office visit may be required. Composite fillings can cost up to twice the cost of amalgams.