We investigate the problem whether two ALC ontologies are indistinguishable (or inseparable) by means of queries in a given signature, which is fundamental for ontology engineering tasks such as ontology versioning, modularisation, update, and forgetting. We consider both knowledge base (KB) and TBox inseparability. For KBs, we give modeltheoretic criteria in terms of (finite partial) homomorphisms and products and prove that this problem is undecidable for conjunctive queries (CQs), but 2ExpTime-complete for unions of CQs (UCQs). The same results hold if (U)CQs are replaced by rooted (U)CQs, where every variable is connected to an answer variable. We also show that inseparability by CQs is still undecidable if one KB is given in the lightweight DL EL and if no restrictions are imposed on the signature of the CQs. We also consider the problem whether two ALC TBoxes give the same answers to any query over any ABox in a given signature and show that, for CQs, this problem is undecidable, too. We then develop model-theoretic criteria for HornALC TBoxes and show using tree automata that, in contrast, inseparability becomes decidable and 2ExpTime-complete, even ExpTime-complete when restricted to (unions of) rooted CQs. module is extracted from an ontology. In ontology update or revision, the difference between the answers to queries over the updated or revised ontology and the original one should be minimised when constructing update or revision operators. Similarly, in forgetting, it is the answers to queries which should be preserved under appropriate forgetting operators. Thus, in the context of query answering, the fundamental relationship between ontologies is not whether they are logically equivalent (have the same models), but whether they give the same answers to any relevant query. To illustrate, consider the following simple TBox T = {Book ∃author.¬Book} saying that every book has an author who is not a book. Clearly, T is not logically equivalent to the TBoxwhich only states that every book has an author. However, if one takes as the query language the popular classes of conjunctive queries (CQs) or unions of CQs (UCQs), then no matter what the data is, every query will have the same answers independently of whether one uses T or T . Intuitively, the reason is that the 'positive' information given by T coincides with the 'positive' information given by T . If the main purpose of the ontology is answering UCQs, it is thus more important to know that T can be safely replaced by T without affecting the answers to UCQs than to establish that T and T are not logically equivalent.In most ontology engineering applications for ontology-based data access, the relevant class Q of queries can be further restricted to those given in a finite signature of relevant concept and role names. For example, to establish that a subset M of an ontology O is a module of O, one should not require that M and O give the same answers to all queries in Q, but only to those that are in the signature of M. Similarly, in the versioning ...