The increasing interconnections of city services, the explosion of available urban data, and the need for multidisciplinary analysis and decision making for city sustainability require new technological solutions to cope with such complexity. Ontologies have become viable and effective tools to practitioners for developing applications requiring data and process interoperability, big data management, and automated reasoning on knowledge. We investigate how and to what extent ontologies have been used to support smart city services and we provide a comprehensive reference on what problems have been addressed and what has been achieved so far with ontology-based applications. To this purpose, we conducted a systematic literature review finalized to presenting the ontologies, and the methods and technological systems where ontologies play a relevant role in shaping current smart cities. Based on the result of the review process, we also propose a classification of the sub-domains of the city addressed by the ontologies we found, and the research issues that have been considered so far by the scientific community. We highlight those for which semantic technologies have been mostly demonstrated to be effective to enhance the smart city concept and, finally, discuss in more details about some open problems.