Skip to content
Advertisement

Creating index if index doesn’t exist

I have a problem creating an index with the advantage database server if it doesn’t exist with a sql query.

My query looks like this:

 If not Exists(<SELECT Query for amount of indizes for one column>) then 
 Create Index Test on Tablename (No); endif

So I don’t use FullTextSearchIndizes,because it is a integer field. Otherwhise it would look like this:

 If not Exists(SELECT * FROM tablename WHERE CONTAINS( * , 'Test' )) then 
 Create Index Test on Tablename (Name) Content; endif     

So, my only problem is how do I get the indices. I’ve read in other DBMS you can use sys.indexes and some other things.

Advertisement

Answer

Take a look at the System tables:

https://devzone.advantagedatabase.com/dz/webhelp/Advantage10/devguide_system_tables.htm

In particular there is a table called system.indexes:

https://devzone.advantagedatabase.com/dz/webhelp/Advantage10/master_system_indexes.htm

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement