MySQL更改表名大小写 [英] MySQL alters table name case

查看:1032
本文介绍了MySQL更改表名大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用MySQL Workbench将我的模型转发工程到工作簿时,它会创建一个脚本文件,并在表名中加上引号.表名全都是大小写混合的,但是当脚本运行时,只有第一个表是大小写混合的,其余的都是小写的.前面显示了20个以上的前两个表:

When I use MySQL Workbench to Forward engineer my model to a work book, it creates a script file with the names of the tables in quotes. The table names are all in mixed case, but when the script runs, only the very first table is created with mixed case and the rest are created only in lower case. The first two tables out of 20+ are shown before:

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';

CREATE SCHEMA IF NOT EXISTS `CCBPlus` ;
USE `CCBPlus` ;

-- -----------------------------------------------------
-- Table `CCBPlus`.`Contacts`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `CCBPlus`.`Contacts` (
  `ContactId` INT(11) NOT NULL,
  `ContactType` BIT(3) NOT NULL COMMENT 'Contact Type: 0=Individual, 1=Corporate,   2=Family, 3=Branch, 4=Department, 5=Group, 6=Fund/GIC/Bank company',
  `DisplayName` VARCHAR(80) NOT NULL,
  `SearchName` VARCHAR(80) NOT NULL,
  `Prefix` VARCHAR(15) NULL DEFAULT NULL,
  `LastName` VARCHAR(50) NULL,
  `Initials` VARCHAR(10) NULL DEFAULT NULL,
  `FirstName` VARCHAR(40) NULL DEFAULT NULL,
  `Suffix` VARCHAR(10) NULL DEFAULT NULL,
  `OrganizationName` VARCHAR(50) NULL DEFAULT NULL,
  `InCareOf` VARCHAR(80) NULL COMMENT 'If mail is to be sent with the line \"In care of  [X]\"',
  `Birthdate` DATETIME NULL DEFAULT NULL,
  `Deceased` DATETIME NULL,
  `SocialSecurityNumber` VARCHAR(20) NULL DEFAULT NULL,
  `Gender` BIT(1) NULL DEFAULT 0 COMMENT '0=Male,1=Female',
  `CulturePreference` VARCHAR(10) NULL DEFAULT 'EN-CA' COMMENT 'Global Culture variable, e.g. EN-CA or FR-CA or other.',
  `LastMeeting` DATETIME NULL DEFAULT NULL,
  `Hobbies` VARCHAR(100) NULL,
  `Inactive` TINYINT(1) NOT NULL DEFAULT False,
  `Created` DATETIME NOT NULL,
  `LastModified` DATETIME NOT NULL,
  PRIMARY KEY (`ContactId`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COMMENT = 'Stores contact and optionally personal information for other' /* comment truncated */ /* entities. */;

-- -----------------------------------------------------
-- Table `CCBPlus`.`Branches`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `CCBPlus`.`Branches` (
  `BranchID` INT NOT NULL AUTO_INCREMENT,
  `Name` VARCHAR(50) NOT NULL COMMENT 'Unique name of this branch.',
  `Code` VARCHAR(4) NOT NULL COMMENT 'Internal code for the branch number.',
  `BranchContactId` INT NULL COMMENT 'Provides the address and contact information for  the branch.',
  `BranchManagerID` INT NULL COMMENT 'ID of the agent that manages this branch.',
  `PartnerDirectOfficerID` INT NULL COMMENT 'ID of the partner that is responsible for  this branch.',
  `HeadOffice` TINYINT(1) NOT NULL DEFAULT False COMMENT 'True if this branch is the head office.',
  `VirtualBranch` TINYINT(1) NOT NULL DEFAULT False COMMENT 'Indicates that this branch  is used only for organizational purposes and is not a real branch.',
  `Inactive` TINYINT(1) NOT NULL DEFAULT False COMMENT 'True if this branch is no longer in use.',
  PRIMARY KEY (`BranchID`),
  CONSTRAINT `fk_Branch_ContactInfo`
    FOREIGN KEY (`BranchContactId`)
    REFERENCES `CCBPlus`.`Contacts` (`ContactId`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_Branch_Manager`
    FOREIGN KEY (`BranchManagerID`)
    REFERENCES `CCBPlus`.`Agents` (`AgentID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_Branch_PartnerDirectOfficer`
    FOREIGN KEY (`PartnerDirectOfficerID`)
    REFERENCES `CCBPlus`.`Agents` (`AgentID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'Can represent a physical branch office, head office or a vir' /* comment truncated */ /*tual branch for organizational purposes.*/;
...

当脚本由MySQL Workbench执行时,一切都可以正常运行,但是最后我得到一张表,其大小写正确:"Contacts",而其他所有表述都只有小写:"branches".

When the script is executed by MySQL Workbench, everything runs correctly, but I end up with one table with the correct cased: 'Contacts', and everything else with only lower case: 'branches'.

我有lower_case_table_names = 2.

I have lower_case_table_names = 2.

我正在运行带有MySQL 5.1.72社区版本的MySQL Workbench版本6.0.9.11421内部版本1170.

I am running MySQL Workbench verson 6.0.9.11421 build 1170 with MySQL 5.1.72 Community version.

任何帮助或建议将不胜感激.

Any help or suggestions would be appreciated.

谢谢,尼尔

推荐答案

向MySQL开发人员报告此错误后,他们回来了,建议我将小写表名设置为零:

After reporting this bug to the MySQL developers, they came back with the suggestion that I set the lower case table names to zero:

lower_case_table_names = 0

在Windows 7开发平台上运行时,此问题已解决.顺便说一句,手动重命名表完全搞砸了我的MySQL Workbench模型和Entity Framework模型.我必须将实体框架模型与数据库重新同步,并再次手动将数据存储表与我的实体进行匹配,然后手动删除创建的额外表和连接.

This fixed the problem, when running on a Windows 7 development platform. BTW, renaming the tables manually totally screwed both my MySQL Workbench Model and my Entity Framework model. I had to resynch the Entity Framework Model with the database and manually match up the datastore tables with my entities again, and then hand-delete the extra tables and connections created.

这篇关于MySQL更改表名大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆