Axter
asked on
List all tables in a database
What is the SQL command to list all tables in a database?
What is the SQL command to list all columns in a table?
What is the SQL command to list all columns in a table?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the syscat tables are simply the views which are based on the sysibm tables.
DB2 LIST TABLES FOR SCHEMA SYSCAT will show you which views are available, they cover the entire range of the database, every object, package, plan, dependancy, relation can be found in these views.
When you say will the sycat tables work with sybase or Btrieve, what exactly do you mean?
DB2 LIST TABLES FOR SCHEMA SYSCAT will show you which views are available, they cover the entire range of the database, every object, package, plan, dependancy, relation can be found in these views.
When you say will the sycat tables work with sybase or Btrieve, what exactly do you mean?
ASKER
>>When you say will the sycat tables work with sybase or Btrieve, what exactly do you mean?
I have a program that can connect to these databases using ODBC.
With ODBC, I can issue a SQL command.
I'm trying to setup my program so I can use the same SQL command for all three database types.
I have a program that can connect to these databases using ODBC.
With ODBC, I can issue a SQL command.
I'm trying to setup my program so I can use the same SQL command for all three database types.
there is no problem for your odbc connection to query the syscat tables, these tables do not have any built security mechanism, they are treated llike any other table
to list all tables use
public static String[] getDatabases(){
databasess = new String[2000];
int teller = 1;
try{
String qry = "Select SYSTEM_TABLE_SCHEMA, SYSTEM_TABLE_NAME, ROW_LENGTH";
qry = qry + " from QSYS2.SYSTABLES where SYSTEM_TABLE_SCHEMA like 'VDR%'";
print(qry);
//print(resultSet.toString ());
resultSet = statement.executeQuery(qry );
while (resultSet.next()) {
String library = resultSet.getString("SYSTE M_TABLE_SC HEMA");
String table = resultSet.getString("SYSTE M_TABLE_NA ME");
int records = resultSet.getInt("ROW_LENG TH");
System.out.println(library +" "+ table+" "+records);
databasess[teller] = library;
print("");
teller++;
}
}
catch (SQLException cnfex) {dbError(cnfex,"ShowDataba ses");}
return databasess;
}
public static String[] getDatabases(){
databasess = new String[2000];
int teller = 1;
try{
String qry = "Select SYSTEM_TABLE_SCHEMA, SYSTEM_TABLE_NAME, ROW_LENGTH";
qry = qry + " from QSYS2.SYSTABLES where SYSTEM_TABLE_SCHEMA like 'VDR%'";
print(qry);
//print(resultSet.toString
resultSet = statement.executeQuery(qry
while (resultSet.next()) {
String library = resultSet.getString("SYSTE
String table = resultSet.getString("SYSTE
int records = resultSet.getInt("ROW_LENG
System.out.println(library
databasess[teller] = library;
print("");
teller++;
}
}
catch (SQLException cnfex) {dbError(cnfex,"ShowDataba
return databasess;
}
ASKER
select * from SYSIBM.SYSTABLES
The above command seem to also pull all the table names.
What is the difference between SYSIBM.SYSTABLES and SYSCAT.TABLES?
Are there other database types that can use SYSCAT.TABLES?
I'm trying to setup my code so that it can work with IBM UDB, Sybase, and Btrieve.
Do you know if SYSCAT.TABLES will work with Sybase or Btrieve?