SAN FRANCISCO — A federal judge in New York has ordered Google to turn over to Viacom a database linking users of YouTube, the Web’s largest video site by far, with every clip they have watched there. The order raised concerns among users and privacy advocates that the online video viewing habits of tens of millions of people could be exposed. But Google and Viacom said they were hoping to come up with a way to protect the anonymity of YouTube viewers. Viacom said that the information would be safeguarded by a protective order restricting access to the data to...