I have a large database that I need to drop and recreate Indexes, the client used SQL 2005 so I created a script to do this. They have now moved on to DB2 but I still need to re Index the tables.
here is an example that I would like to get converted to DB2 syntax, all tables and Indexes are the same in both databases. The alter statement I would guess to be the same the one I dont know is the ( IF EXISTS) statement, will it work in DB2
IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[myco].[Access
Sets]') AND name = N'PK_AccessSets')
ALTER TABLE [myco].[AccessSets] DROP CONSTRAINT [PK_AccessSets]
ALTER TABLE [myco].[AccessSets] ADD CONSTRAINT [PK_AccessSets] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]