2

What would be the query to check that a table exists in Informix ?

1 Answer 1

3

To check whether an Informix table exists, use the following query:

SELECT       COUNT(*) 
       FROM  systables 
       WHERE tabname = 'yourtablename';

If the result is not 0, then the table exists.

2
  • 1
    This is the simple answer and it works fine in most databases as long as you're not using trick names (ones that need DELIMIDENT set in the environment) and you specify the table name in lower-case letters. If your database is MODE ANSI, you might get back an answer bigger than one; in those databases, the combination of owner and tablename is unique. Dealing with "what is the TabID of a given table name" is trickier, in general, because of these complexities. Commented Sep 30, 2016 at 7:20
  • @JonathanLeffler thank you for comment. The database was not MODE ANSI. This answer worked. :) Commented Sep 30, 2016 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.