Chris wrote:
MySQL has a really nice syntax for creating tables if they don't exist already:

CREATE TABLE IF NOT EXISTS foo (...)

How can I get the same functionality in Derby? I haven't been able to figure out the SQL command to check for the existence of a table.

You can use this (Scala code follows):

      val metadata = connection.getMetaData
      val rs = metadata.getTables(null,
                                  null,
                                  null,
                                  Array("TABLE"))

This should work for any database, but I know it works for Derby, PostgreSQL and Oracle.

Regards,
Blair

Reply via email to