This article needs additional citations for verification. (February 2014) ( Learn how and when to remove this template message)
An oil well is a boring in the Earth that is designed to bring petroleum oil hydrocarbons to the surface. Usually some natural gas is released along with the oil. A well that is designed to produce only gas may be termed a gas well.
The earliest known oil wells were drilled in China in 347 CE. These wells had depths of up to about 240 metres (790 ft) and were drilled using bits attached to bamboo poles.  The oil was burned to evaporate brine and produce salt. By the 10th century, extensive bamboo pipelines connected oil wells with salt springs. The ancient records of China and Japan are said to contain many allusions to the use of natural gas for lighting and heating. Petroleum was known as Burning water in Japan in the 7th century. 
According to Kasem Ajram, petroleum was distilled by the Persian alchemist Muhammad ibn Zakarīya Rāzi (Rhazes) in the 9th century, producing chemicals such as kerosene in the alembic (al-ambiq), [ verification needed] and which was mainly used for kerosene lamps.  Arab and Persian chemists also distilled crude oil in order to produce flammable products for military purposes. Through Islamic Spain, distillation became available in Western Europe by the 12th century. 
Some sources claim that from the 9th century, oil fields were exploited in the area around modern Baku, Azerbaijan, to produce naphtha for the petroleum industry. These places were described by Marco Polo in the 13th century, who described the output of those oil wells as hundreds of shiploads. When Marco Polo in 1264 visited Baku, on the shores of the Caspian Sea, he saw oil being collected from seeps. He wrote that "on the confines toward Geirgine there is a fountain from which oil springs in great abundance, in as much as a hundred shiploads might be taken from it at one time." 
In 1846, Baku (settlement Bibi-Heybat) the first ever well was drilled with percussion tools to a depth of 21 meters for oil exploration. In 1848, the first modern oil well was drilled on the Absheron Peninsula north-east of Baku, by Russian engineer F.N. Semyenov. 
Ignacy Łukasiewicz, a Polish   pharmacist and petroleum industry pioneer built one of the world's first modern oil wells in 1854 in Polish village Bóbrka, Krosno County  who in 1856 built one of the world's first oil refineries. 
In North America, the first commercial oil well entered operation in Oil Springs, Ontario in 1858, while the first offshore oil well was drilled in 1896 at the Summerland Oil Field on the California Coast.
The earliest oil wells in modern times were drilled percussively, by repeatedly raising and dropping a cable tool into the earth. In the 20th century, cable tools were largely replaced with rotary drilling, which could drill boreholes to much greater depths and in less time. The record-depth Kola Borehole used non-rotary mud motor drilling to achieve a depth of over 12,000 metres (39,000 ft).
Until the 1970s, most oil wells were vertical, although lithological and mechanical imperfections cause most wells to deviate at least slightly from true vertical. However, modern directional drilling technologies allow for strongly deviated wells which can, given sufficient depth and with the proper tools, actually become horizontal. This is of great value as the reservoir rocks which contain hydrocarbons are usually horizontal or nearly horizontal; a horizontal wellbore placed in a production zone has more surface area in the production zone than a vertical well, resulting in a higher production rate. The use of deviated and horizontal drilling has also made it possible to reach reservoirs several kilometers or miles away from the drilling location (extended reach drilling), allowing for the production of hydrocarbons located below locations that are either difficult to place a drilling rig on, environmentally sensitive, or populated.
Before a well is drilled, a geologic target is identified by a geologist or geophysicist to meet the objectives of the well.
- For a production well, the target is picked to optimize production from the well and manage reservoir drainage.
- For an exploration or appraisal well, the target is chosen to confirm the existence of a viable hydrocarbon reservoir or to learn its extent.
- For an injection well, the target is selected to locate the point of injection in a permeable zone, which may support disposing of water or gas and /or pushing hydrocarbons into nearby production wells.
The target (the end point of the well) will be matched with a surface location (the starting point of the well), and a trajectory between the two will be designed.
When the well path is identified, a team of geoscientists and engineers will develop a set of presumed properties of the subsurface that will be drilled through to reach the target. These properties include pore pressure, fracture gradient, wellbore stability, porosity, permeability, lithology, faults, and clay content. This set of assumptions is used by a well engineering team to perform the casing design and completion design for the well, and then detailed planning, where, for example, the drill bits are selected, a BHA is designed, the drilling fluid is selected, and step-by-step procedures are written to provide instruction for executing the well in a safe and cost-efficient manner.
The well is created by drilling a hole 12 cm to 1 meter (5 in to 40 in) in diameter into the earth with a drilling rig that rotates a drill string with a bit attached. After the hole is drilled, sections of steel pipe ( casing), slightly smaller in diameter than the borehole, are placed in the hole. Cement may be placed between the outside of the casing and the borehole known as the annulus. The casing provides structural integrity to the newly drilled wellbore, in addition to isolating potentially dangerous high pressure zones from each other and from the surface.
With these zones safely isolated and the formation protected by the casing, the well can be drilled deeper (into potentially more-unstable and violent formations) with a smaller bit, and also cased with a smaller size casing. Modern wells often have two to five sets of subsequently smaller hole sizes drilled inside one another, each cemented with casing.
- To drill the well
- The drill bit, aided by the weight of the drill string above it, cuts into the rock. There are different types of drill bit; some cause the rock to disintegrate by compressive failure, while others shear slices off the rock as the bit turns.
- Drilling fluid, a.k.a. "mud", is pumped down the inside of the drill pipe and exits at the drill bit. The principal components of drilling fluid are usually water and clay, but it also typically contains a complex mixture of fluids, solids and chemicals that must be carefully tailored to provide the correct physical and chemical characteristics required to safely drill the well. Particular functions of the drilling mud include cooling the bit, lifting rock cuttings to the surface, preventing destabilisation of the rock in the wellbore walls and overcoming the pressure of fluids inside the rock so that these fluids do not enter the wellbore. Some oil wells are drilled with air or foam as the drilling fluid.
- The generated rock " cuttings" are swept up by the drilling fluid as it circulates back to surface outside the drill pipe. The fluid then goes through " shakers" which strain the cuttings from the good fluid which is returned to the pit. Watching for abnormalities in the returning cuttings and monitoring pit volume or rate of returning fluid are imperative to catch "kicks" early. A "kick" is when the formation pressure at the depth of the bit is more than the hydrostatic head of the mud above, which if not controlled temporarily by closing the blowout preventers and ultimately by increasing the density of the drilling fluid would allow formation fluids and mud to come up through the annulus uncontrollably.
- The pipe or drill string to which the bit is attached is gradually lengthened as the well gets deeper by screwing in additional 9 m (30 ft) sections or "joints" of pipe under the kelly or topdrive at the surface. This process is called making a connection, or "tripping". Joints can be combined for more efficient tripping when pulling out of the hole by creating stands of multiple joints. A conventional triple, for example, would pull pipe out of the hole three joints at a time and stack them in the derrick. Many modern rigs, called "super singles", trip pipe one at a time, laying it out on racks as they go.
This process is all facilitated by a drilling rig which contains all necessary equipment to circulate the drilling fluid, hoist and turn the pipe, control downhole, remove cuttings from the drilling fluid, and generate on-site power for these operations.
After drilling and casing the well, it must be 'completed'. Completion is the process in which the well is enabled to produce oil or gas.
In a cased-hole completion, small holes called perforations are made in the portion of the casing which passed through the production zone, to provide a path for the oil to flow from the surrounding rock into the production tubing. In open hole completion, often 'sand screens' or a 'gravel pack' is installed in the last drilled, uncased reservoir section. These maintain structural integrity of the wellbore in the absence of casing, while still allowing flow from the reservoir into the wellbore. Screens also control the migration of formation sands into production tubulars and surface equipment, which can cause washouts and other problems, particularly from unconsolidated sand formations of offshore fields.
After a flow path is made, acids and fracturing fluids may be pumped into the well to fracture, clean, or otherwise prepare and stimulate the reservoir rock to optimally produce hydrocarbons into the wellbore. Finally, the area above the reservoir section of the well is packed off inside the casing, and connected to the surface via a smaller diameter pipe called tubing. This arrangement provides a redundant barrier to leaks of hydrocarbons as well as allowing damaged sections to be replaced. Also, the smaller cross-sectional area of the tubing produces reservoir fluids at an increased velocity in order to minimize liquid fallback that would create additional back pressure, and shields the casing from corrosive well fluids.
In many wells, the natural pressure of the subsurface reservoir is high enough for the oil or gas to flow to the surface. However, this is not always the case, especially in depleted fields where the pressures have been lowered by other producing wells, or in low permeability oil reservoirs. Installing a smaller diameter tubing may be enough to help the production, but artificial lift methods may also be needed. Common solutions include downhole pumps, gas lift, or surface pump jacks. Many new systems in the last ten years have been introduced for well completion. Multiple packer systems with frac ports or port collars in an all in one system have cut completion costs and improved production, especially in the case of horizontal wells. These new systems allow casings to run into the lateral zone with proper packer/frac port placement for optimal hydrocarbon recovery.
The production stage is the most important stage of a well's life; when the oil and gas are produced. By this time, the oil rigs and workover rigs used to drill and complete the well have moved off the wellbore, and the top is usually outfitted with a collection of valves called a Christmas tree or production tree. These valves regulate pressures, control flows, and allow access to the wellbore in case further completion work is needed. From the outlet valve of the production tree, the flow can be connected to a distribution network of pipelines and tanks to supply the product to refineries, natural gas compressor stations, or oil export terminals.
As long as the pressure in the reservoir remains high enough, the production tree is all that is required to produce the well. If the pressure depletes and it is considered economically viable, an artificial lift method mentioned in the completions section can be employed.
Workovers are often necessary in older wells, which may need smaller diameter tubing, scale or paraffin removal, acid matrix jobs, or completing new zones of interest in a shallower reservoir. Such remedial work can be performed using workover rigs – also known as pulling units, completion rigs or "service rigs" – to pull and replace tubing, or by the use of well intervention techniques utilizing coiled tubing. Depending on the type of lift system and wellhead a rod rig or flushby can be used to change a pump without pulling the tubing.
Enhanced recovery methods such as water flooding, steam flooding, or CO2 flooding may be used to increase reservoir pressure and provide a "sweep" effect to push hydrocarbons out of the reservoir. Such methods require the use of injection wells (often chosen from old production wells in a carefully determined pattern), and are used when facing problems with reservoir pressure depletion, high oil viscosity, or can even be employed early in a field's life. In certain cases – depending on the reservoir's geomechanics – reservoir engineers may determine that ultimate recoverable oil may be increased by applying a waterflooding strategy early in the field's development rather than later. Such enhanced recovery techniques are often called " tertiary recovery".
A well is said to reach an "economic limit" when its most efficient production rate does not cover the operating expenses, including taxes. 
The economic limit for oil and gas wells can be expressed using these formulae:
is an oil well's economic limit in oil barrels per month (bbls/month).
is a gas well's economic limit in thousand standard cubic feet per month (MSCF/month).
are the current prices of oil and gas in dollars per barrels and dollars per MSCF respectively.
is the lease operating expenses in dollars per well per month.
working interest, as a fraction. 
net revenue interest, as a fraction.
gas/oil ratio as SCF/bbl.
condensate yield as barrel/million standard cubic feet.
production and severance taxes, as a fraction.
When the economic limit is raised, the life of the well is shortened and proven oil reserves are lost. Conversely, when the economic limit is lowered, the life of the well is lengthened.
When the economic limit is reached, the well becomes a liability and is abandoned. In this process, tubing is removed from the well and sections of well bore are filled with concrete to isolate the flow path between gas and water zones from each other, as well as the surface. Completely filling the well bore with concrete is costly and unnecessary. The surface around the wellhead is then excavated, and the wellhead and casing are cut off, a cap is welded in place and then buried.
At the economic limit there often is still a significant amount of unrecoverable oil left in the reservoir. It might be tempting to defer physical abandonment for an extended period of time, hoping that the oil price will go up or that new supplemental recovery techniques will be perfected. In these cases, temporary plugs will be placed downhole and locks attached to the wellhead to prevent tampering. There are thousands of "abandoned" wells throughout North America, waiting to see what the market will do before permanent abandonment. Often, lease provisions and governmental regulations usually require quick abandonment; liability and tax concerns also may favor abandonment. 
In theory an abandoned well can be reentered and restored to production (or converted to injection service for supplemental recovery or for downhole hydrocarbons storage), but reentry often proves to be difficult mechanically and expensive. Traditionally elastomer and cement plugs have been used with varying degrees of success and reliability. Over time, they may deteriorate, particularly in corrosive environments, due to the materials from which they are manufactured. Conventional bridge plugs also have very small expansion ratios, limiting them for use in wells with restrictions. Alternatively, high expansion plugs, such as inflatable packers, do not have the differential pressure capabilities required for many well abandonments, nor do they provide a gas-tight seal. New tools have been developed that make re-entry easier, these tools offer higher expansion rations than conventional bridge plugs and higher differential pressure ratings than inflatable packers, all while providing a V0 rated, gas tight seal that cement cannot provide. 
- Wells that produce oil
- Wells that produce oil and natural gas, or
- Wells that only produce natural gas.
Natural gas is almost always a byproduct of producing oil, since the small, light gas carbon chains come out of solution as they undergo pressure reduction from the reservoir to the surface, similar to uncapping a bottle of soda where the carbon dioxide effervesces. Unwanted natural gas can be a disposal problem at the well site. If there is not a market for natural gas near the wellhead it is virtually valueless since it must be piped to the end user. Until recently, such unwanted gas was burned off at the wellsite, but due to environmental concerns this practice is becoming less common.  Often, unwanted (or 'stranded' gas without a market) gas is pumped back into the reservoir with an 'injection' well for disposal or repressurizing the producing formation. Another solution is to export the natural gas as a liquid. Gas to liquid (GTL) is a developing technology that converts stranded natural gas into synthetic gasoline, diesel or jet fuel through the Fischer-Tropsch process developed in World War II Germany. Such fuels can be transported through conventional pipelines and tankers to users. Proponents claim GTL fuels burn cleaner than comparable petroleum fuels. Most major international oil companies are in advanced development stages of GTL production, e.g. the 140,000 bbl/d (22,000 m3/d) Pearl GTL plant in Qatar, scheduled to come online in 2011. In locations such as the United States with a high natural gas demand, pipelines are constructed to take the gas from the wellsite to the end consumer.
Wells can be located:
- On land, or
Offshore wells can further be subdivided into
- Wells with subsea wellheads, where the top of the well is sitting on the ocean floor under water, and often connected to a pipeline on the ocean floor.
- Wells with 'dry' wellheads, where the top of the well is above the water on a platform or jacket, which also often contains processing equipment for the produced fluid.
While the location of the well will be a large factor in the type of equipment used to drill it, there is actually little difference in the well itself. An offshore well targets a reservoir that happens to be underneath an ocean. Due to logistics, drilling an offshore well is far more costly than an onshore well. By far the most common type is the onshore well. These wells dot the Southern and Central Great Plains, Southwestern United States, and are the most common wells in the Middle East.
Another way to classify oil wells is by their purpose in contributing to the development of a resource. They can be characterized as:
- wildcat wells are drilled where little or no known geological information is available. The site may have been selected because of wells drilled some distance from the proposed location but on a terrain that appeared similar to the proposed site.
- exploration wells are drilled purely for exploratory (information gathering) purposes in a new area, the site selection is usually based on seismic data, satellite surveys etc. Details gathered in this well includes the presence of Hydrocarbon in the drilled location, the amount of fluid present and the depth at which oil or/and gas occurs.
- appraisal wells are used to assess characteristics (such as flow rate, reserve quantity) of a proven hydrocarbon accumulation. The purpose of this well is to reduce uncertainty about the characteristics and properties of the hydrocarbon present in the field.
- production wells are drilled primarily for producing oil or gas, once the producing structure and characteristics are determined.
- development wells are wells drilled for the production of oil or gas already proven by appraisal drilling to be suitable for exploitation.
- Abandoned well are wells permanently plugged in the drilling phase for technical reasons.
At a producing well site, active wells may be further categorised as:
- oil producers producing predominantly liquid hydrocarbons, but mostly with some associated gas.
- gas producers producing almost entirely gaseous hydrocarbons.
- water injectors injecting water into the formation to maintain reservoir pressure, or simply to dispose of water produced with the hydrocarbons because even after treatment, it would be too oily and too saline to be considered clean for dumping overboard offshore, let alone into a fresh water resource in the case of onshore wells. Water injection into the producing zone frequently has an element of reservoir management; however, often produced water disposal is into shallower zones safely beneath any fresh water zones.
- aquifer producers intentionally producing water for re-injection to manage pressure. If possible this water will come from the reservoir itself. Using aquifer produced water rather than water from other sources is to preclude chemical incompatibility that might lead to reservoir-plugging precipitates. These wells will generally be needed only if produced water from the oil or gas producers is insufficient for reservoir management purposes.
- gas injectors injecting gas into the reservoir often as a means of disposal or sequestering for later production, but also to maintain reservoir pressure.
Lahee classification 
- New Field Wildcat (NFW) – far from other producing fields and on a structure that has not previously produced.
- New Pool Wildcat (NPW) – new pools on already producing structure.
- Deeper Pool Test (DPT) – on already producing structure and pool, but on a deeper pay zone.
- Shallower Pool Test (SPT) – on already producing structure and pool, but on a shallower pay zone.
- Outpost (OUT) – usually two or more locations from nearest productive area.
- Development Well (DEV) – can be on the extension of a pay zone, or between existing wells (Infill).
The cost of a well depends mainly on the daily rate of the drilling rig, the extra services required to drill the well, the duration of the well program (including downtime and weather time), and the remoteness of the location (logistic supply costs).
The daily rates of offshore drilling rigs vary by their capability, and the market availability. Rig rates reported by industry web service  show that the deepwater water floating drilling rigs are over twice that of the shallow water fleet, and rates for jackup fleet can vary by factor of 3 depending upon capability.
With deepwater drilling rig rates in 2015 of around $520,000/day,  and similar additional spread costs, a deep water well of duration of 100 days can cost around US$100 million.
With high performance jackup rig rates in 2015 of around $177,000,  and similar service costs, a high pressure, high temperature well of duration 100 days can cost about US$30 million.
Onshore wells can be considerably cheaper, particularly if the field is at a shallow depth, where costs range from less than $1 million to $15 million for deep and difficult wells.[ citation needed]
The total cost of an oil well mentioned does not include the costs associated with the risk of explosion and leakage of oil. Those costs include the cost of protecting against such disasters, the cost of the cleanup effort, and the hard-to-calculate cost of damage to the company's image.
- "ASTM International - Standards Worldwide". www.astm.org.
- Joseph P. Riva Jr. and Gordon I. Atwater. "petroleum". Encyclopædia Britannica. Retrieved 2008-06-30.
- Dr. Kasem Ajram (1992). The Miracle of Islam Science (2nd ed.). Knowledge House Publishers. ISBN 0-911119-43-4.
- Zayn Bilkadi ( University of California, Berkeley), "The Oil Weapons", Saudi Aramco World, January–February 1995, pp. 20–7
- Steil, Tim. Fantastic Filling Stations. Voyageur Press. p. 18. ISBN 9781610606295.
- "History of the Oil Industry". www.sjvgeology.org.
- Magdalena Puda-Blokesz, Ignacy Łukasiewicz: ojciec światowego przemysłu naftowego, działacz polityczny i patriota, filantrop i społecznik, przede wszystkim CZŁOWIEK Archived 2014-10-27 at the Wayback Machine
- Ludwik Tomanek, Ignacy Łukasiewicz twórca przemysłu naftowego w Polsce, wielki inicjator - wielki jałmużnik. — Miejsce Piastowe: Komitet Uczczenia Pamięci Ignacego Łukasiewicza — 1928
- Warsaw University timeline Archived 2007-05-19 at the Wayback Machine
- Frank, Alison Fleig (2005). Oil Empire: Visions of Prosperity in Austrian Galicia (Harvard Historical Studies). Harvard University Press. ISBN 0-674-01887-7.
- Mohammed A. Mian, Petroleum Engineering Handbook for the Practicing Engineer, Tulsa, Okla.: PennWell, 1992, p.447.
- "working interest - Schlumberger Oilfield Glossary". www.glossary.oilfield.slb.com.
- Frosch, Dan; Gold, Russell (26 February 2015). "How 'Orphan' Wells Leave States Holding the Cleanup Bag". Wall Street Journal. Retrieved 26 February 2015.
- "Rigless Well Abandonment for the Oil & Gas Industry".
- Emam, Eman A. (December 2015). "GAS FLARING IN INDUSTRY: AN OVERVIEW" (PDF). large.stanford.edu/.
- Rigzone - Rig day rates : http://www.rigzone.com/data/dayrates/
|Wikimedia Commons has media related to Oil wells.|
- Halliburton Technical Papers
- Freemyer Industrial Pressure
- Schlumberger Oilfield Glossary
- The History of the Oil Industry
- "Black Gold" Popular Mechanics, January 1930 - large photo article on oil drilling in the 1920s and 1930s
- "World's Deepest Well" Popular Science, August 1938, article on the late 1930s technology of drilling oil wells
- 'Ancient Chinese Drilling'[ permanent dead link] article from June 2004 CSEG Recorder