I have csv file and i want to import that data to oracle database. but before that i want it to check whether table 'xyz' exist in database or not.
I want to do it through java .. anyone knows how to do it through java ?
You can use the available meta data:
DatabaseMetaData meta = con.getMetaData();
ResultSet res = meta.getTables(null, null, null,
new String[] {"TABLE"});
while (res.next()) {
System.out.println(
" "+res.getString("TABLE_CAT")
+ ", "+res.getString("TABLE_SCHEM")
+ ", "+res.getString("TABLE_NAME")
+ ", "+res.getString("TABLE_TYPE")
+ ", "+res.getString("REMARKS"));
}
See here for more details.
Wikipedia has some good info on getting at oracle metadata.
SELECT
COUNT(1)
FROM
ALL_TABLES
WHERE
TABLE_NAME = 'NAME_OF_TABLE'
Replace NAME_OF_TABLE with the name of your table and if you get a result of 1, you have your table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With