PDA

View Full Version : SQL Command to check table existence



Guest.Visitor
01-01-1995, 02:00 AM
Is there a direct SQL command to check the existence of a table without using CL program. Like in MS SQL, they have SYSOBJECTS to check existence of a table. Thank you very much for any help I could get.

Guest.Visitor
06-12-2000, 05:22 AM
Emer, You could read the system catalog to check to see whether a table exists. The table you need to use to check for a file's existance is systables. Something like select count(*) from systables where table_name = 'MYTABLE' should work. There are other system catalog files containing fields, views, indexes, procedures, etc. David Morris

Guest.Visitor
08-10-2000, 12:20 PM
select count(*) from systables where table_name = '<tablename>' This will give you a numeric response of 0 or greater than 0 if the table exists. Remember that systables are in lib qsys2. Hope this helps!