Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
| Search | Today's Posts | Mark Forums Read
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 21st, 2006, 12:26 PM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default Cant ADD CONSTRAINT (ergent)

Hi there:
I have 2 tables & I want to add forien key CONSTRAINT between them as:
Code:
ALTER TABLE `test`.`t_InquiredProforma`
ADD CONSTRAINT `FK_t_InquiredProforma_1` FOREIGN KEY `FK_t_InquiredProforma_1`
(`bPartnerId`) REFERENCES `t_BusinessPartner` (`bPartnerId`)
    ON DELETE CASCADE
    ON UPDATE RESTRICT;

but it gives me an error
Can't create table '.\test\#sql-57c_3a.frm' (errno: 150)

Please help me.
tnx in advance.

My tables r as below:
Code:
CREATE TABLE  `test`.`t_InquiredProforma` (
  `serial` bigint(20) NOT NULL default '0',
  `salesmanProformaSerial` varchar(255) default NULL,
  `date` date default NULL,
  `validity` date default NULL,
  `warehousingExp` int(11) default NULL,
  `consideration` varchar(255) default NULL,
  `discount` int(11) default NULL,
  `deposit` bigint(20) default NULL,
  `status` varchar(255) default NULL,
  `acceptedByManager` tinyint(1) default NULL,
  `acceptedByCommision` tinyint(1) default NULL,
  `selected` tinyint(1) default NULL,
  `totalCost` bigint(20) default NULL,
  `bPartnerId` bigint(20) NOT NULL default '0',
  `t_PurchaseOrder_serial` bigint(20) NOT NULL default '0',
  PRIMARY KEY  (`serial`)
) TYPE=InnoDB;


CREATE TABLE  `test`.`t_BusinessPartner` (
  `bPartnerId` bigint(20) unsigned NOT NULL default '0',
  `t_BusinessPartner_KargozarId` bigint(20) unsigned default NULL,
  `name` varchar(255) NOT NULL default '',
  `economicalCode` varchar(255) default NULL,
  `webSite` varchar(255) default NULL,
  `email` varchar(255) default NULL,
  `telephone1` varchar(255) NOT NULL default '',
  `telephone2` varchar(255) default NULL,
  `fax` varchar(255) default NULL,
  `postalCode` varchar(255) default NULL,
  `postBox` varchar(255) default NULL,
  `address` varchar(255) default NULL,
  `level` varchar(255) NOT NULL default '',
  `type` varchar(255) NOT NULL default '',
  `category` varchar(255) NOT NULL default '',
  `commissionEvaluation` varchar(255) default NULL,
  `manager` varchar(255) default NULL,
  `tradeManager` varchar(255) default NULL,
  `id` bigint(20) default NULL,
  `manager_fk` int(11) default NULL,
  `tradeManager_fk` int(11) default NULL,
  `businesspartner_fk` bigint(20) default NULL,
  PRIMARY KEY  (`bPartnerId`)
) TYPE=InnoDB;


Always:),
Hovik Melkomian.
__________________
Always,
Hovik Melkomian.
 
Old February 28th, 2006, 02:05 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

ok guys I got it!

Always:),
Hovik Melkomian.
 
Old March 6th, 2006, 04:02 AM
Friend of Wrox
 
Join Date: Nov 2005
Location: Rotterdam, , Netherlands.
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

What was the solution? I have the same trouble.

thnx

__________________________________________________ ________
This is my junk I'm gona eat it
 
Old April 18th, 2006, 01:16 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Well I dont have a long experiance in MySql but as I got since now MySql is so sensitive or has not the good performance as I felf in MS-SQL & Oracle!
Anyway the things u should check is:
1_ Primary & Forien key must be in DataType
2_ Check unsign tag in ur table
3_ Both tables must be in same Engine

HTH.

Always:),
Hovik Melkomian.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I have a constraint like this.....? callagga SQL Language 7 August 13th, 2008 01:08 AM
How can i add constraint on update cascade without mahen_pali SQL Server 2005 1 May 3rd, 2008 03:28 PM
Constraint Vs Index carumuga SQL Server 2000 2 December 4th, 2007 02:14 AM
How to add constraint to access bounded form. method Access 1 June 28th, 2005 10:39 AM
Access SQL alter table add constraint Skipmeok SQL Language 0 April 27th, 2004 08:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.