我正在按照链接创建mysql表
但我一直在犯这个错误
FOREIGN KEY (serial_no) REFERENCES tag_master(orig_serial_no) ON UPDATE CASCADE ON DELETE RESTRICT:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for
mysql> create database test;
Query OK, 1 row affected (0.01 sec)
mysql> use test;
Database changed
mysql> create table one (id int not null primary key);
Query OK, 0 rows affected (0.03 sec)
mysql> -- here is the problem
mysql> create table two (oneid int not null references one(id)
在MySQL中,我有一种很好的方法来抑制键检查,我就是这样做的:
SET FOREIGN_KEY_CHECKS = 0;
在那之后,我可以轻易地放下任何一张桌子。我想,在Postgresql中,如果我运行的话,我也可以这样做:
SET CONSTRAINTS ALL DEFERRED;
但问题是,当我尝试删除一些表之后,我会得到一个错误列表,表示某个表依赖于另一个表blablabla。那么,我做错了什么,我该如何解决呢?谢谢!
所以..。这是我的代码:
$paymentType=$_POST["paymentType"]; // in the first two lines the $_POST data is copied into normal variables to make it easier to handle
$paymentMethod=$_POST["paymentMethod"];
$amount=$_POST["amount"];
$date=$_POST["date"];
$other=$_POST["other"
我遇到了删除外键索引的问题,我总是得到相同的错误
ALTER TABLE `comments` DROP INDEX `id_user`
哪种输出
1025 - Error on rename of './postuj_cz1/#sql-d834_a0c704'
to './postuj_cz1/comments' (errno: 150)
另一个表上的id_user是简单的主键索引。
我使用的是MySQL版本5.0.85