mysql 设置表名大写_MySQL更改表名大小写

bd96500e110b49cbb3cd949968f18be7.png

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.*/;

...

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

I have lower_case_table_names = 2.

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.

Thanks, Neil

解决方案

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

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值