Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with table creation error [ was: Please help]

    Hi There,
    I am a newbie in MySQL
    I am having some difficulties in figuring out the problems of the following error. Please advice.

    SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
    SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
    SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

    -- -----------------------------------------------------
    -- Schema emtdb
    -- -----------------------------------------------------

    USE `emtdb` ;

    -- -----------------------------------------------------
    -- Table `emtdb`.`Customer`
    -- -----------------------------------------------------
    CREATE TABLE IF NOT EXISTS `emtdb`.`Customer` (
    `UUID` VARCHAR(36) NOT NULL,
    `CustomerNumber` INT NOT NULL,
    `CreationDate` DATETIME NOT NULL,
    `Company Name` TEXT NOT NULL,
    `Business Number` TEXT NULL,
    `Address 1` TEXT NOT NULL,
    `Address 2` TEXT NULL,
    `Address 3` TEXT NULL,
    `Phone 1` TEXT NULL,
    `Phone 2` TEXT NULL,
    `Fax 1` TEXT NULL,
    `Fax 2` TEXT NULL,
    `State` TEXT NULL,
    `Country` TEXT NOT NULL,
    `PostalCode` TEXT NULL,
    PRIMARY KEY (`UUID`),
    UNIQUE INDEX `CustomerNumber_UNIQUE` (`CustomerNumber` ASC),
    UNIQUE INDEX `CustomerUUID_UNIQUE` (`UUID` ASC))
    ENGINE = InnoDB
    COMMENT = 'Customer information such as name, country and unique identifier.';


    -- -----------------------------------------------------
    -- Table `emtdb`.`Contacts`
    -- -----------------------------------------------------
    CREATE TABLE IF NOT EXISTS `emtdb`.`Contacts` (
    `UUID` VARCHAR(36) NOT NULL,
    `CustomerUUID` VARCHAR(36) NOT NULL,
    `First Name` VARCHAR(45) NOT NULL,
    `Middle Name` VARCHAR(45) NULL,
    `Last Name` VARCHAR(45) NULL,
    `Phone 1` VARCHAR(45) NULL,
    `Phone 2` VARCHAR(45) NULL,
    `Fax 1` VARCHAR(45) NULL,
    `Mobile 1` VARCHAR(45) NULL,
    `Mobile 2` VARCHAR(45) NULL,
    `Position` TEXT NULL,
    PRIMARY KEY (`UUID`, `CustomerUUID`),
    INDEX `fk_Contacts_Customers1_idx` (`CustomerUUID` ASC),
    CONSTRAINT `fk_Contacts_Customers1`
    FOREIGN KEY (`CustomerUUID`)
    REFERENCES `emtdb`.`Customer` (`UUID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
    ENGINE = InnoDB
    COMMENT = 'Contacts - whom may be linked to a supplier or customer';

    The error is as follows:
    1050 table 'Customer' already exist
    1050 table 'Contacts' already exist

  • #2
    New Coder
    Join Date
    Jun 2005
    Location
    Blackpool. UK
    Posts
    98
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Delete the existing tables before trying to create them would be one solution.


    Failing that repair all the tables in the database

    mysqlcheck -A --auto-repair
    Chris

    Indifference will be the downfall of mankind, but who cares?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •