I am trying to create a table in a Database that stores information/ metadata about other databases. More precisely I have two databases, each one containing a number of tables, and in my newly created database I need to build a table, which stores the matadata of thoses databases, like for example the name of a relation, field etc of thoses other databases.
I am not sure on how to access/ use this metadata though. To create my new db/ table I of course opened a connection using jdbc. And to access the other databases I attached them.
If this is the table I created, which I want to fill with metadata:
CREATE TABLE SCHEMAINFO (db_name VARCHAR, rel_name VARCHAR, field_name VARCHAR);
and this is part of the metadata I want to fill it with:
CREATE table faculty (head VARCHAR(20), numberEmployees INT, department VARCHAR(20))
and this is how I want it to be:
INSERT INTO SCHEMAINFO (University, facutly, head);
INSERT INTO SCHEMAINFO (University, facutly, numberEmployees);
INSERT INTO SCHEMAINFO (University, facutly, department);
How can I address those variables? If I have as a resultSet the 'create'-statement of a table? Is it even possible? I basically don't know anything about the databases I am using, other then their names, so I can't call the varibales directly.
I tried to do this (University is the name of one of the databases I am trying to access)
ResultSet rs = stmt.executeQuery("SELECT * FROM University.sqlite_master WHERE type='table';");
while(rs.next()){
String temp = rs.getString(5);
}
Aucun commentaire:
Enregistrer un commentaire