Davis has its own Amtrak station located at the edge of downtown. The Capital Corridor goes through Davis from Sacramento.
Ticket Information
You can plan your route and buy Amtrak tickets online. You will get a QR code that you will show the conductor after you have boarded the train. Tickets can be a little pricey and will usually take longer than driving, but taking the train can be less of a headache than having to drive in California traffic for several hours. Once you buy your ticket, My main problem is that Amtrak is suseptible to delays, so you may be waiting at the station for a while.
Commuting via Amtrak
I know some people commute from Sacramento to Davis via Amtrak. It's important to know that Amtrak often experiences signficant delays and is pretty hit or miss on whether it is going to show up on time. If I was on a strict timeline, I probably wouldn't take the train.
Long Trips via Amtrak
I think Amtrak is at its best when you are going on a long trip and are not in a rush. The routes are often very scenic and tranquil. A long Amtrak trip is a great time for you to get some work done, meet new people, or just relax and enjoy the scenery.