Mysql中没用InnoDB实现外键约束的例子(DDL)

# ---------------------------------------
# Host     : localhost
# Port     : 3306
# Database : chho


SET FOREIGN_KEY_CHECKS=0;

DROP DATABASE IF EXISTS `chho`;

CREATE DATABASE `chho`;

USE `chho`;

#
# Structure for the `power_person` table :
#

CREATE TABLE `power_person` (
  `POWER_USER_ID` varchar(255) NOT NULL default '',
  `POWER_USER_LEVEL` int(11) default NULL,
  `POWER_OTHER` varchar(255) default NULL,
  PRIMARY KEY  (`POWER_USER_ID`),
  KEY `FK38F5D2E586CA74B5` (`POWER_USER_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

#
# Structure for the `person` table :
#

CREATE TABLE `person` (
  `USER_ID` varchar(255) NOT NULL default '',
  `NAME` varchar(16) NOT NULL default '',
  `PASSWORD` varchar(16) NOT NULL default '',
  PRIMARY KEY  (`USER_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

#
# Structure for the `guest_person` table :
#

CREATE TABLE `guest_person` (
  `GUEST_USER_ID` varchar(255) NOT NULL default '',
  `GUEST_OTHER` varchar(255) default NULL,
  PRIMARY KEY  (`GUEST_USER_ID`),
  KEY `FKB62739F25ED19688` (`GUEST_USER_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
========================================================
alter table GUEST_USER drop constraint FKB62739F25ED19688;
alter table POWER_USER drop constraint FK38F5D2E586CA74B5;
drop table if exists USER;
drop table if exists GUEST_USER;
drop table if exists POWER_USER;
create table USER (USER_ID varchar(255) not null,NAME varchar(16) not null,PASSWORD varchar(16) not null,primary key (USER_ID));
create table GUEST_USER (GUEST_USER_ID varchar(255) not null,GUEST_OTHER varchar(255),primary key (GUEST_USER_ID));
create table POWER_USER (POWER_USER_ID varchar(255) not null,POWER_USER_LEVEL integer,POWER_OTHER varchar(255),primary key (POWER_USER_ID));
alter table GUEST_USER add index FKB62739F25ED19688 (GUEST_USER_ID), add constraint FKB62739F25ED19688 foreign key (GUEST_USER_ID) references USER (USER_ID);
alter table POWER_USER add index FK38F5D2E586CA74B5 (POWER_USER_ID), add constraint FK38F5D2E586CA74B5 foreign key (POWER_USER_ID) references USER (USER_ID);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值