Oil light coming on randomly

With oil light on disconnect wire to sensor.If it stays lit there is a bad wire /grounding out going to oil switch sensor

Car and year? It is possible disconnecting the wire and failure condition produce the same results. Howmany miles and what are the oil and filter change intervals.