How can I attach legs to a table?
I would not weaken your legs by drilling huge two inch holes in them. Instead you could consider the leg attachment scheme as shown below. A heavy duty lag/stud bolt is screwed into the table leg. The upper inside corner of the 4x4 leg can be cut at a 45 degree angle as shown below to make it easier to drill the lag bolt into the leg.

The skirt boards that go between the legs are notched and an angled cross member is glued and screwed into the inside face of the skirt boards. The angle cut on the inner corner of the leg can also allow the cross member to get closer to the leg and be a shorter piece. A shorter cross piece will have less chance to flex. When a hex nut and washer are installed onto the threaded end of the stud an extremely strong leg attachment is created. Obviously the width of the skirt boards (top to bottom dimension) can be increased to as much as possible to increase stability of the leg attachment. In fact if the skirt board is wide enough it is possible to even use two lag bolts into the leg for even more strength.