While alcohol is served in some hotels and sold in a few designated stores, it may generally only be purchased by people who hold a liquor license. Yes. A personal liquor license.
People who consume or possess alcohol are required to have a Ministry of Interior liquor permit or they may face arrest, fines and possible imprisonment. Yes, alcohol is served in most major hotel bars, but technically that's only for guests of the hotel. People who consume alcohol in a hotel who aren't staying there are required to have their own personal liquor license.
Liquor licenses are only issued to people who possess current UAE residency permits and who are non-Muslim. The penalties for Muslims who are intoxicated are more severe and do include corporal punishment such as lashings.
Just about any public activity that you can think of that involves alcohol is illegal. Drinking or being drunk in public is illegal, and believe it or not, the police are actually fairly good at spotting a drunk tourist and the defense of "But I've only had a few!" isn't considered a valid legal defense in the UAE and you may face immediate arrest and imprisonment simply for being drunk or drinking in public.
Driving with any amount of alcohol in your system is illegal and the penalties can be very draconian, so it really is something to avoid.
Travellers arrested for any form of alcohol related incident are typically jailed for many days while awaiting a court hearing. The penalties for any form of alcohol related offense tend to be quite severe and increase in severity where driving and injury are concerned. Penalties include lengthy imprisonment (think years not months), fines and for Muslim travellers, even those not from the UAE, lashings.
Note that the liquor licenses are Emirate specific, and a liquor license issued for Dubai only allows you to drink in Dubai. A separate liquor license is required for each Emirate.