In previous posts I have given examples of using the CREATE OR REPLACE for all kinds of SQL objects: Views, Indexes, Functions, Triggers, Sequences, etc. One situation I have not mentioned is using this option when creating a Table. I know it sounds a bit scary to replace an existing Table that contains data. If I am going to do it I want to have the option to preserve the data or to delete it.
Creating a new table is as easy as:
01 CREATE TABLE MYLIB.TESTING_TABLE
02 FOR SYSTEM NAME "TESTTABLE"
03 (
04 FIRST_COLUMN FOR "FIRST" VARCHAR(10) NOT NULL,
05 IDENTITY_COLUMN FOR "ID_COL" BIGINT
06 GENERATED ALWAYS AS IDENTITY
07 ) ;
08 INSERT INTO MYLIB.TESTTABLE (FIRST_COLUMN)
09 VALUES('FIRST'),('SECOND'),('THIRD') ; |


