SHARE
TWEET

Untitled

a guest Jul 17th, 2017 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #REVISO SI EXISTE LA TABLA
  2.  
  3. SELECT table_name
  4. FROM information_schema.tables
  5. WHERE table_schema = 'senu'
  6. AND table_name = 'abono';
  7.  
  8. #EL SELECT NO RETORNA NADA
  9.  
  10. #CREO LA TABLA
  11.  
  12. SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
  13. SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
  14. SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
  15.  
  16. CREATE  TABLE IF NOT EXISTS `senu`.`abono` (
  17.   `id` INT(11) NOT NULL AUTO_INCREMENT ,
  18.   `nfact` INT(11) NOT NULL ,
  19.   `fecha` DATETIME NULL DEFAULT NULL ,
  20.   `abono` DECIMAL(19,4) NULL DEFAULT NULL ,
  21.   PRIMARY KEY (`id`) ,
  22.   CONSTRAINT `fk_abono_factura1`
  23.     FOREIGN KEY (`nfact` )
  24.     REFERENCES `senu`.`factura` (`nfact` )
  25.     ON DELETE NO ACTION
  26.     ON UPDATE NO ACTION)
  27. ENGINE = InnoDB
  28. DEFAULT CHARACTER SET = latin1
  29. COLLATE = latin1_swedish_ci;
  30.  
  31.  
  32. SET SQL_MODE=@OLD_SQL_MODE;
  33. SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  34. SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  35.  
  36. #RETORNA: ERROR: Error 1050: Table '`senu`.`abono`' already exists
RAW Paste Data
Top