-- #################################
-- ### CONSULTORIA NUTRICIONAL #####
-- #################################

-- ###### BACKUP DAS TABELAS #######

CREATE TABLE NUTRIENTE_BKP AS SELECT * FROM NUTRIENTE
/
CREATE TABLE NUTRPROD_BKP AS SELECT * FROM NUTRPROD
/
CREATE TABLE GRUPNUTR_BKP AS SELECT * FROM GRUPNUTR
/
CREATE TABLE NUTRECOM_BKP AS SELECT * FROM NUTRECOM
/
CREATE TABLE GREQUIVALE_BKP AS SELECT * FROM GREQUIVALE
/
CREATE TABLE LIMNUTRI_BKP AS SELECT * FROM LIMNUTRI
/
CREATE TABLE DIAGNUTR_BKP AS SELECT * FROM DIAGNUTR
/
CREATE TABLE TRABNUTRIREC_BKP AS SELECT * FROM TRABNUTRIREC
/                
CREATE TABLE PRINATIVNUTR_BKP AS SELECT * FROM PRINATIVNUTR
/
CREATE TABLE NUTRNECE_BKP AS SELECT * FROM NUTRNECE
/
CREATE TABLE NUTRECOMPACI_BKP AS SELECT * FROM NUTRECOMPACI
/
CREATE TABLE ITEQUIVALE_BKP AS SELECT * FROM ITEQUIVALE
/
CREATE TABLE CARDPADR_BKP AS SELECT * FROM CARDPADR
/        
CREATE TABLE CARDCONSNUTR_BKP AS SELECT * FROM CARDCONSNUTR
/        
CREATE TABLE PARAMGERAL_BKP AS SELECT CDPARGERAL, CDPROTEINA, CDLIPIDIOS, CDCARBOHIDRA, CDALCOOL, CDPROTANIMAL, CDPROTVEGETA, CDACUCARES, CDACIDGRAXOS, CDCALORIAS FROM PARAMGERAL
/
CREATE TABLE PARAMPLANEJA_BKP AS SELECT * FROM PARAMPLANEJA
/

-- ### EXCLUSÃO DOS REGISTROS ######

UPDATE PARAMGERAL
  SET CDPROTEINA=NULL, CDLIPIDIOS=NULL, CDCARBOHIDRA=NULL,  CDALCOOL=NULL,                                        CDPROTANIMAL=NULL, CDPROTVEGETA=NULL, CDACUCARES=NULL, CDACIDGRAXOS=NULL,
                       CDCALORIAS=NULL
/
UPDATE PARAMPLANEJA
       SET CDNUTRRELAT1 = NULL, CDNUTRRELAT2 = NULL, CDNUTRRELAT3 = NULL, CDNUTRRELAT4 = NULL
/
DELETE FROM LIMNUTRI
/
DELETE FROM DIAGNUTR
/
DELETE FROM TRABNUTRIREC
/
DELETE FROM PRINATIVNUTR
/
DELETE FROM NUTRNECE
/
DELETE FROM NUTRECOMPACI
/
DELETE FROM ITEQUIVALE
/
DELETE FROM CARDPADR
/
DELETE FROM CARDCONSNUTR
/
DELETE FROM NUTRPROD
/
DELETE FROM NUTRECOM
/
DELETE FROM GREQUIVALE
/
DELETE FROM NUTRIENTE
/
DELETE FROM GRUPNUTR
/
DROP TRIGGER TD_GREQUIVALE
/
DROP TRIGGER TD_NUTRIENTE
/

-- ## CASO SEJA NECESSÁRIO VOLTAR O BACKUP ##
-- ## REALIZAR O COMANDO PARA CADA TABELA  ##

-- ALTER TABLE GRUPNUTR RENAME TO GRUPNUTR_B
--/
--ALTER TABLE GRUPNUTR_BKP RENAME TO GRUPNUTR
--/
