I have two questions about REFERENCES:
1. It appears that mySQL treats REFERENCES associated with an
attribute differently than FOREIGN KEY (<blah>) REFERENCES...
Specifically, the first form does not appear to work, while the later
does. Here's a simple example (slightly edited):
mysql> CREATE TABLE person (id char(5) primary key);
Query OK, 0 rows affected (0.04 sec)
mysql> CREATE TABLE phone (id char(5) not null REFERENCES person(id),
num char(10) not null, PRIMARY KEY (id, num));
Query OK, 0 rows affected (0.06 sec)
mysql> show create table phone;
| phone | CREATE TABLE `phone` (
`id` char(5) NOT NULL default '',
`num` char(10) NOT NULL default '',
PRIMARY KEY (`id`,`num`)
) TYPE=InnoDB CHARSET=latin1 |
1 row in set (0.00 sec)
mysql> insert into phone value ('foo', 'bar');
Query OK, 1 row affected (0.04 sec)
It appears that the constraint is not created and is certainly not
enforced. Now consider what should be the same phone table.
mysql> drop table phone;
Query OK, 0 rows affected (0.29 sec)
mysql> CREATE TABLE phone (id char(5) not null, num char(10) not null,
PRIMARY KEY (id, num), FOREIGN KEY (id) REFERENCES person(id));
Query OK, 0 rows affected (0.09 sec)
mysql> show create table phone;
| Table | Create Table
| phone | CREATE TABLE `phone` (
`id` char(5) NOT NULL default '',
`num` char(10) NOT NULL default '',
PRIMARY KEY (`id`,`num`),
FOREIGN KEY (`id`) REFERENCES `person` (`id`)
) TYPE=InnoDB CHARSET=latin1 |
1 row in set (0.00 sec)
mysql> insert into phone values ('foo', 'bar');
ERROR 1216: Cannot add or update a child row: a foreign key constraint
fails
Why are these different?
2. In the manual (and in several posts), it clearly states (see
Section 7.5.4.2 of the 4.1.0-alpha manual)
"Both tables have to be InnoDB type and there must be an index where
the foreign key and the referenced key are listed as the FIRST
columns"
However, I did not create an indicies, but it worked. What's up?
Thanks in advance 0 1479 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: francescomoi |
last post by:
Hi.
I'm trying to build 'MySQL-python-1.2.0' on my Linux FC2:
----------------------------------
# export PATH=$PATH:/usr/local/mysql/bin/
# export mysqlclient=mysqlclient_r
# python setup.py clean
# python setup.py build
running build
running build_py
|
by: Randell D. |
last post by:
Folks,
I have installed MySQL v4 (client, server and development rpm's). I've
tried and failed to use the recommended mysqladmin to set a root password
after the installation (I have another post open on the MySQL newsgroup
about this). I'm attempting an alternative solution and using webmin
(www.webmin.com) to create/manage access to my databases.
Webmin reports "Warning: The Perl module DBD::mysql is not installed on your
system, so...
|
by: Ed Smith |
last post by:
I have two questions about REFERENCES:
1. It appears that mySQL treats REFERENCES associated with an
attribute differently than FOREIGN KEY (<blah>) REFERENCES...
Specifically, the first form does not appear to work, while the later
does. Here's a simple example (slightly edited):
mysql> CREATE TABLE person (id char(5) primary key);
Query OK, 0 rows affected (0.04 sec)
|
by: mikey |
last post by:
Hi all,
I'm having great problems trying to install the latest MySQl RPM
package onto my Red Hat Linux OS.
There is already MySQL v 3.0 pre-installed with the RH Linux
distribution disk but I can not seem to get any of the functions
working on it. So I have now dopwnloaded the latest version hoping
that this will fix the error.
I have managed to install the MySQL-shared-compat-4.0.1-0.i386.rpm but
|
by: MLH |
last post by:
Cardinality?
I hear it spoken of by MySQL users. Does it
matter to MS Access if MySQL tables are
attached via ODBC?
| |
by: Karl O. Pinc |
last post by:
FYI,
It'd be nice if the error message from a REFERENCES
constraint mentioned the column name into which
the bad data was attempted to be inserted.
In PostgreSQL 7.3:
sandbox=> insert into foo (id, b) values (3, 2);
ERROR: b_is_fkey referential integrity violation - key referenced from
|
by: trihanhcie |
last post by:
I m currently working on a Unix server with a fedora 3 as an os
My current version of mysql is 3.23.58. I'd like to upgrade the version
to 5.0.18.
After downloading from MYSQL.COM the package on the site, I made :
rpm -i MySQL-server-5.0.18-0.i386.rpm
then i have errors that relate to many conflicts. I cannot figure out
why -and- cannot upgrade. Please Help !
|
by: manish deshpande |
last post by:
Hi,
When i'm installing MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm by the following command:
rpm -i MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm the following error is being shown:
warning: MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
file /etc/my.cnf from install of MySQL-server-standard-5.0.24a-0.rhel3 conflicts with file from package mysql-3.23.58-1
file...
|
by: menzies |
last post by:
Hi, I"m new to this forum, but I have been trying all day to install DBD::mysql onto my Intel MacBook. I've read lots of forums pages and none have gotten me to a successful 'make test' or a successful 'sudo make install.' Before every attempt I even do a sudo make distclean to make sure I haven't gotten things mucked up from a prior attempt.
OS: Mac OS X 10.4.10
MySQL: v5.0.41 for Mac OSX-i686
DBI: v1.58 (installed fine using CPAN)...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |