Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

H2: how to tell if index exists?

Tags:

java

sql

h2

I can use CREATE TABLE IF NOT EXISTS to create a table only if it doesn't exist.

How can i do the same for CREATE INDEX.. to only create it if it doesn't exist?

like image 783
daniels Avatar asked Aug 29 '14 16:08

daniels


1 Answers

You can do it as follows,

CREATE INDEX IF NOT EXISTS NEW_INDEX_NAME ON TABLE_NAME;

You can follow link aswell, http://www.h2database.com/html/grammar.html#create_index

like image 67
Niru Avatar answered Nov 09 '22 20:11

Niru