By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,584 Members | 1,750 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,584 IT Pros & Developers. It's quick & easy.

filter systables from ado recordset adSchemaTables (repost)

P: n/a
Hello,
I want to list all the user-tables of a DB2 database. I use the
ADO-openSchema method (adSchemaTables), but I can't filter the
systables out.
Has someone any idea how to select only the user tables? (on a generic
way)
Regards,
Thijs

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 2004-12-14, th**********@gmail.com scribbled:
I want to list all the user-tables of a DB2 database. I use the
ADO-openSchema method (adSchemaTables), but I can't filter the
systables out.
Has someone any idea how to select only the user tables? (on a generic
way)


Hi Thijs,

All the system tables, views, etc. exist within the SYSCAT, SYSIBM,
SYSFUN, and SYSSTAT schemas. Additionally, you are not permitted to
create any tables or views within these schemas:

"CREATE TABLE statement
....
table-name
Names the table. The name, including the implicit or explicit
qualifier, must not identify a table, view, nickname, or alias
described in the catalog. The schema name must not be SYSIBM, SYSCAT,
SYSFUN, or SYSSTAT (SQLSTATE 42939)..."

Ergo, if a table or view exists within any of these schemas, it is a
system table.

One final note of caution: I was once in a similar situation, having to
discern which tables were system tables in an application (to filter
them from the list given to end users), and decided to take a more
general approach.

On the basis of the following content from the DB2 SQL Reference:

"CREATE SCHEMA Statement
....
schema-name
Names the schema. The name must not identify a schema already described
in the catalog (SQLSTATE 42710). The name cannot begin with 'SYS'
(SQLSTATE 42939)..."

I decided that, since you cannot even create schemas that begin with
"SYS", it would be enough to check whether the schema for a given table
began with "SYS". If it did, it was a system table. However, this
turned out to be wrong.

Although one cannot _explicitly_ create a schema that begins with SYS,
one can do so _implicitly_. For example, this command will fail:

CREATE SCHEMA SYSTEST;

However, this command succeeds:

CREATE TABLE SYSTEST.TEST (A INTEGER NOT NULL);
HTH,

Dave.
--
Cogito cogito ergo cogito sum
-- Ambrose Bierce
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.