In the spirit of test-driven design I want to test whether the tables get properly created in my SQLite3 database. For that purpose I want to list the table names via an SQL query.
I created the tables with:
public static void setupTables(){
try(Statement stmt = con.createStatement()) {
String sql_student = ("CREATE TABLE IF NOT EXISTS " + STUDENT_TABLE + "(\n "
+ ID + " integer PRIMARY KEY,\n "
+ FIRSTNAME + " text,\n "
+ LASTNAME + " text\n"
+ ");");
String sql_teacher = ("CREATE TABLE IF NOT EXISTS " + TEACHER_TABLE + "(\n "
+ ID + " integer PRIMARY KEY,\n "
+ FIRSTNAME + " text,\n "
+ LASTNAME + " text\n"
+ ");");
stmt.execute(sql_student);
stmt.execute(sql_teacher);
stmt.close();
}catch(Exception e){
e.printStackTrace();
}
}
What's the query I need for my test? Do I need to be concerned about order, or does the order in which the tables get created gurantee that they will always stored in the same order?