There were two kinds of formal dinners held by Navy commands. One was a "dining in" and the other was a "dining out." For a dining out, the officers and their spouses attended. For a dining in, it was only the officers, though the commanding officer of the next higher unit was typically invited.
They are generally held in home port at the base officer's club and, for small ships, held with the permission of the squadron commander, because all of the officers attend, which means that one of the most senior chief petty officers is the command duty officer for the event (typically, the officer who would have been the CDO does not drink for the event.) Attire is "mess dress", which basically for women was Service Dress Blue/White with a long skirt. For male lieutenants and below, that was Service Dress Blue with a bow tie or Service Dress Whites; for lieutenant commanders and above, it was a form of tuxedo jacket. Service Dress Whites, colloquially known as "chocker whites," were best worn on those occasions when an adequate blood supply to the brain was not necessary, for if an officer had put on a significant amount of weight, well, you get the picture.
The two key people at a dining in were the Captain and a junior officer who was designated as "Mr. (or Ms.) Vice." Mr. Vice was the enforcer of the rules of the occasion and he levied fines for not wearing the uniform correctly or swearing or not toasting with a full glass or smoking when not authorized.
There was a cocktail hour before the dinner, then the dinner began. The main course was always roast beef, with the first slice served to the Captain, who tasted it and then pronounced: "This beef is fit for human consumption." As the meal went on, Mr. Vice turned to his main duty, which was making sure everyone got shitfaced. This was done by frequent toasts, first to the President of the United States, then to the Commodore (if he attended the dinner) and then to the Captain. After that, the toasts were up to the imagination of Mr. Vice.
The best toast I ever heard was: "To the Russian Navy, for without them, we'd all be in the Coast Guard." One lieutenant was aghast at that toast, but the Captain thought it was very appropriate. If you read this, it probably will not surprise you to learn that the officer who made the toast was an OCS grad who got out after six years and the aghast LT was a Boat School grad who eventually became a flag officer.
The amount of drinking at a dining in began to taper off in the mid 1980s when the Navy started to get really serious about drinking and driving and then drinking in general. Up until then, getting blasted on shore leave/liberty ("shore leave" was the term for officers, "liberty" was the term for enlisted, though the colloquial term was "hitting the beach") was sort of a badge of honor, as in "it takes a real sailor to get blasted on the beach."
One time I drove a shipmate to his house after a dining in, because I had been careful with my drinking and he hadn't. I had a fairly new car at the time, the first new car I ever owned, and I told him that if he puked in my car, I was going to roll him into a drainage ditch and stand on his head. He didn't puke; I got him to his house and his thoroughly disgusted wife (it was well after midnight) and I managed to get his carcass inside the house. We dumped him on the living room floor, she threw a blanket over him, took his shoes off, put a pillow under his head and somewhat sarcastically thanked me for bringing him home.
Oh, the irony...
1 hour ago