Unanswered: Creating DB objects if they don't exist
In SQL Server I am able to create a .sql script for creating tables, with statements like:
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[MySchema].[MyTable]') AND type in (N'U'))
CREATE TABLE [MySchema].[MyTable](
[Number] [int] ,
This ensures that I can run the script daily and any new tables added in the script get created without affecting my original tables.
How can I do this in DB2? Does DB2 support having CREATE statements in an IF statement?
you could just execute the create table stmnt
if table exists you get sql code indicating already exists -- will not be executed
do not include any drop stmnt
Best Regards, Guy Przytula
Database Software Consultant
Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
Information Server Datastage Certified http://www.infocura.be