An oil well is a shaft drilled through a portion of the Earth’s crust for the purpose of retrieving raw petroleum products. From the well's conception to its abandonment, it undergoes several stages of development. Oil wells can be drilled in a variety of locations and do not all yield the same product. They will always produce at least a small amount of natural gas, which may or may not be captured for sale.
The earliest recorded oil well was constructed in 347 CE in China and the technology had spread to Japan by the seventh century. These simple drilling constructions, made of bamboo, were replaced as the technology and processes were refined. The modern age brought oil wells drilled with a stiff cable and then rotary drills. Modern drilling techniques allow for almost horizontal drilling, providing access to oil reserves that are deep underground.
The drilling begins once a suitable site has been selected and all the plans have been finalized. A hole between 5 and 50 inches (12.7 to 91.4 cm) is drilled. This section is the widest segment of the hole, as each subsequent segment drilled will be slightly smaller, in order to reduce any pressure build up from below. After each section is drilled, a casing, made of steel, is placed within the hole and cemented in place. There are usually no more than five successive segments drilled in any one hole.
The oil well must be completed, meaning that it must be adapted for oil production and harvesting. Often the pressure that has built up within the reserve is strong enough to force the oil out on its own, but if the pressure level is insufficient, a pump is installed instead. The oil is then collected by a series of valves known as production trees set atop the installation. These keep track of the oil pressure within the well and adjust accordingly. Eventually, the installation will be abandoned when it is no longer profitable to operate.
An oil well may produce primarily oil or gas and can produce both. Small amounts of natural gas, which is a byproduct of the creation of the petroleum itself, are present in every oil well. Some wells produce almost entirely gas.
Oil wells can be located either onshore or offshore. The well's function is the same regardless of location, but due to the difficulty of drilling and maintaining a well in the ocean, offshore wells are much more expensive. These wells are drilled only when the presence of a substantial amount of petroleum has been proven. They also require more planning and have more safety requirements.