The previous article simply described the requirements for foreign key constraints, and did not tell you about the referential actions of foreign key constraints. This time I'll take a look at the update operation under the FOREIGN KEY
Label: Business Requirements: User table R_user Save the user name and other information. Now need to set up a work base for each user, a user can have more than one work base, multiple users can also have a work base, that is, many-to-many relationships. (Foreign key, if there are two table a,b,c is the primary key of a, and B also has a C
');2. Query two tables at the same time, the Cartesian product of the table, resulting in two table length of the product query, there should be enough constraints. because field names in multiple tables may be duplicated, use the table name. field syntax to access, you can easily query the name of the table after the alias (the space after the alias). Querying
There are two main problems: 1. Blocking during DML operations, ii. Speed problems during DML operations I. Blocking problems when the foreign key is not indexed and the field associated with the foreign key in the primary table is updated, level 4 lock (S) needs to be added
problem above is that the country_id field cannot be changed because of association.Then I read the book again and found that My SQL statement does not have the innodb foreign key constraint (cascade, set null, no action, restrict ), I feel that this is where my problem is.But how can we join the association method? There is no proper way to
Define a data table if a computer manufacturer stores the product information of the entire machine and accessories in its database. The table used to save the product information of the entire machine is called pc; the table used to save the accessory supply information is called parts. In the pc table, there is a field used to describe the CPU model used by this computer. in the parts table, there is a field
Use [Master]GoSet ansi_nulls onGoSet quoted_identifier onGo/* | **************************************** ************************************Software name: May Flower ERPCopyright: (c) 2005-2006 may flower ERP development teamObject Name: sp_helptableObject Author: lvqyCreated on: 2005-12-04Modification record:Function Description: obtains the creation script of a specified table, including the table and field attributes and
found to exist, records can be saved in the zoo table.
To delete a foreign key relationship, use show create table to find the internal tag of InnoDB, as shown in table B:
Table B
+-------+---------------------------------------------------+
|Table|CreateTable|
+-------+---------------------------------------------------+
|zoo|CREATETABLE`zoo`(
`id`int(4)NOTNULLdefault'0',
`name`varchar
most of the time foreign keys (and other constraints) are necessary.
Foreign keys require additional overhead to reduce performanceAny code has overhead, and the key is not worth it. Do nothing, is the fastest, do not need to spend time.Because the correctness of the data is crucial, it is certainly worthwhile to use for
\mysql\problem\pic\02.jpgThen see the table involving the foreign key has jbpm4_variable, Jbpm4_execution, jbpm4_swimlane three tables, then clear the three table data can be.
Mysql> Delete from jbpm4_variable;Query OK, 1404 rows affected (0.03 sec)mysql> Delete Fromjbpm4_swimlane;Query OK, rows affected (0.03 sec)Mysql> Delete from jbpm4_execution; # Here the error is because the table itself
To add a PRIMARY KEY constraint:ALTER TABLE ga_airline ADD CONSTRAINT pk_airline_id PRIMARY KEY (airline_id);There are three types of foreign KEY constraints:1. Normal FOREIGN KEY constraint (cannot delete parent table record if t
is not NULL,... Field definition ...};
Set Index
To set a foreign key, the corresponding two fields must be indexed (index) in the reference table (referencing table, PC tables) and referenced tables (referenced table, parts tables).
For parts table:
ALTER TABLE Parts ADD INDEX Idx_model (model);
To add an index to the Parts table, the index is built
A foreign key specifies that the value of a column (or a group of columns) must conform to the values of some rows in another table. We say this is to maintain the referential integrity of the associated table.In the graphical interface, the Foreign key tab simply clicks on the Outer
Mysql foreign key creation problem mysql foreign key creation error 150 Mysql error: error Code: 1005. can't create table 'joblog. SC '(errno: 150) create table SC (id int (10) unsigned not null auto_increment comment 'id', Sno int (10) unsigned not null default '0' comment 'student ID ', Cno int (10) unsigned not null
You need to delete the foreign key and primary key first, and store data by creating temporary fields (to reserve the customer's original data ), finally, re-establish the primary key and foreign key 1. Delete the relationship bet
Label:If Table A's primary key is a field in table B, the field is called the Foreign key of Table B, table A is called the primary table, and table B is called from the table. The foreign key
An error like this cannot create a. frm file seems to imply incorrect permissions or other reasons for operating system files, but in reality, this MySQL error has been reported as a bug in MySQL itself and has been in the MySQL developer list for many years, Yet this seems another misleading.In many instances, this error occurs because MySQL has always been unable to support the relationship of the problem, and, unfortunately, it does not indicate exactly which one of the problems will lead to
Tags: delete default har primary key LAN char check tar cannotWhen you create a foreign key in MySQL, you often fail because there are a lot of details in MySQL that we need to keep in mind, and the following are some common reasons why I have summarized and consulted the data myself. 1. The type or size of the two fields does not match exactly. For example, if o
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.