Germany's top court has upheld the legality of an anti-terrorism database, but has ordered the government to tweak how it is operated.

The database was created to help investigators better track down suspects by consolidating police and intelligence service data in one place.

The government says the database, established in 2007, now contains information on 17,000 people.

Opponents had challenged its legality, arguing controls on how authorities use it are not tight enough.

The Federal Constitutional Court in Karlsruhe ruled Wednesday that the database does not violate any rights guaranteed by the constitution, but ordered the government to make certain changes by the end of 2014.

Among other things it says to ensure legal "transparency and control" parameters need to be established compelling regular reports to Parliament on the database.