473,511 Members | 15,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dropping an unnamed constraint

Hi everyone. I need to drop a foreign key constraint from a table (or
add an "ON DELETE SET DEFAULT") but the constraint is unnamed. Is
there anyway to do that? I looked online but didn't find anything.

-Brandon

Sep 12 '06 #1
3 6201
Brandon wrote:
Hi everyone. I need to drop a foreign key constraint from a table (or
add an "ON DELETE SET DEFAULT") but the constraint is unnamed. Is
there anyway to do that? I looked online but didn't find anything.
Use "SHOW CREATE TABLE tablename". It'll show you the constraint name,
which was generated automatically by MySQL when you declared the foreign
key.

Example:

create table prim (i int primary key);
create table fore (i int, foreign key (i) references prim(i));

show create table fore;

CREATE TABLE `fore` (
`i` int(11) default NULL,
KEY `i` (`i`),
CONSTRAINT `fore_ibfk_1` FOREIGN KEY (`i`) REFERENCES `prim` (`i`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

Regards,
Bill K.
Sep 13 '06 #2
Hi everyone. I need to drop a foreign key constraint from a table (or
add an "ON DELETE SET DEFAULT") but the constraint is unnamed. Is
there anyway to do that? I looked online but didn't find anything.

Use "SHOW CREATE TABLE tablename". It'll show you the constraint name,
which was generated automatically by MySQL when you declared the foreign
key.

<SNIP>
Actually, I tried that and it still didn't show an identifier.

Sep 17 '06 #3
Brandon wrote:
>Use "SHOW CREATE TABLE tablename". It'll show you the constraint name,

Actually, I tried that and it still didn't show an identifier.
This may be dependent on the version of MySQL you use. I tested the
example I gave, using MySQL 5.0.24. What version are you using?

Regards,
Bill K.
Sep 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4494
by: Ron | last post by:
Mandatories: Ver 7.3.4, Redhat Linux 8.0, P4, 2GB RAM I want to add a 'nullable' foreign key to a column in a table. I have tables "company" and "project" which may be related by...
3
3470
by: sashi | last post by:
Hi, Is it possible to use wildards in SQL to drop a constraint on a table? Thanks!
1
1451
by: jbtaylor16 | last post by:
I have several default constraints defined on a table. When I use the Object Browser and expand the constraints for this table and right-click and then select "Script Object to New Window As...
2
10108
by: yongsing | last post by:
I have two tables as shown below (only relevant columns shown). The second table is dependent on the first one. CREATE TABLE PARENTTABLE ( ... SERIAL CHAR(12) NOT NULL, ENDDATE TIMESTAMP NOT...
3
1948
by: geoffrobinson | last post by:
In Microsoft SQL Server, I have a documents table and a table which categorizes the documents, which we'll call categories. I tried running UPDATE statements on the categories table previously...
3
15868
by: Jeff Kish | last post by:
Hi. I'm getting errors like this when I try to run an upgrade script I'm trying to write/test: altering labels to length 60 Server: Msg 5074, Level 16, State 4, Line 5 The object...
9
2299
by: Tom Plunket | last post by:
The project I'm currently on makes heavy use of unnamed structures to represent an "object hierarchy" of a sort. E.g. struct BaseObject { int aMember; int anotherMember; // etc.
1
2124
by: abhu50 | last post by:
i have created table with unnamed check constraint so pl help me to drop this check constraint also about dropping the foreign key that is unnamed???????????
1
1566
by: LogicMechanic | last post by:
I need to add a constraint to every varchar column in an entire database to not allow '<script>' to be inserted or updated. Any resource you know of that would explain how I would go about this? I...
0
7245
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7144
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...
0
7356
Oralloy
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,...
0
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7085
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...
0
4741
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...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1577
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 ...
0
449
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.