The war, now in its seventh month, has killed more than 34,000 Palestinians, according to Gaza health authorities
Police said the attack was "not an act of terror". They said they had identified the attacker, but did not name him, describing him in a statement appealing for help from the public as bald, unkempt and around 190 cm (six feet three inches) tall.
The attack happened inside an office building on a shopping street in the centre of Schaffhausen, a medieval town of 36,000 inhabitants on the German border, police said.
Police cordoned off the area and ordered people to leave, Swiss newspaper Blick said. Witnesses saw bleeding victims being treated by rescue crews, it reported.
Helicopter ambulances were on the scene.