Skip to content

Instantly share code, notes, and snippets.

@phpdave
Last active October 5, 2016 12:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpdave/60b755b20c77d06b5717 to your computer and use it in GitHub Desktop.
Save phpdave/60b755b20c77d06b5717 to your computer and use it in GitHub Desktop.
--Create backup
CREATE TABLE MYLIB.MYTABLEBACKUP
AS (SELECT * FROM MYLIB.MYTABLE)
WITH DATA;
--::WARN:: This will tell the server to drop columns even if there is data in the column
CALL QSYS2.QCMDEXC('ADDRPYLE SEQNBR(1500) MSGID(CPA32B2) RPY(''I'')');
CALL QSYS2.QCMDEXC('CHGJOB INQMSGRPY(*SYSRPYL)');
--Alter table, drop column and add column
ALTER TABLE MYLIB.MYTABLE DROP COLUMN OLDCOLUMNNAME ;
ALTER TABLE MYLIB.MYTABLE ADD COLUMN NEWCOLUMNNAME CHARACTER (1) ;
--Pull the data back in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment