如题,怎么让A数据库的表里面的字段参照B数据库的表的字段
举个例子
数据库A:
create table aDB
(
Aid int(8) not null
)数据库B:
create table bDB
(
Bid int(8) not null
)怎么让Bid 参照 Aid
举个例子
数据库A:
create table aDB
(
Aid int(8) not null
)数据库B:
create table bDB
(
Bid int(8) not null
)怎么让Bid 参照 Aid
解决方案 »
- Mysql 错误,求高手指教,谢谢了!!在线等 Can't create table (errno: -1)
- 如何把sql server的数据库导入Oracle中
- 提问:SQL中的INSERT INTO ... SELECT ...
- Mysql GUI Tools连接问题?
- 请教mysql数据库还原的问题
- 怎样更新php的mysql库?
- MYSQL触发器问题
- 怎么从excel表中导入数据
- 创建不同的用户存储信息,是在数据库可创建表空间,还是在创建个数据库
- 安装mysql-connector-net-6.6.4 总是失败 your system has not been mofifiel
- 乱码问题
- 关于MySQL的复制的一个小问题
mysql> create table test.aDB
-> (
-> Aid int(8) not null primary key
-> );
Query OK, 0 rows affected (0.09 sec)mysql> create table csdn.bDB
-> (
-> Bid int(8) not null,
-> CONSTRAINT FOREIGN KEY(Bid) REFERENCES test.aDB(Aid)
-> );
Query OK, 0 rows affected (0.13 sec)mysql> insert into test.aDB values (1);
Query OK, 1 row affected (0.06 sec)mysql> insert into csdn.bDB values (3);
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint f
ails (`csdn`.`bdb`, CONSTRAINT `bdb_ibfk_1` FOREIGN KEY (`Bid`) REFERENCES `test
`.`adb` (`Aid`))
mysql> insert into csdn.bDB values (1);
Query OK, 1 row affected (0.06 sec)