Reputation: 3536
I am working on a Java UI application that uses JDBC. I assume the database I'm working in is already existing. However, the tables the program refers to may not necessarily exist.
Thus, only on first use, I'd like to check if these tables exist, and if not, create them.
Upvotes: 3
Views: 2959
Reputation: 31627
While creating table say
CREATE TABLE IF NOT EXISTS ......
See this for more information.
CREATE TABLE IF NOT EXISTS Employee (id INT);
This works with mysql, sql, PostgreSQL, Oracle
Upvotes: 4