The basic process of a database is to see what libraries are in your database: show databases;
Then go to the corresponding library to operate: Use+ Enter the library/table switch path
To view all the tables in this library:
Show Tabales;
View all of the information in this table:
Select * from + table name;
FOREIGN Key:
Foreign keys are like the attributes of some characters in your table. The attributes of many characters are the same or the attributes are repeated by many people. If you write Chinese characters such as ' the five-crossing vocational Technical College of Beijing Hai Ding District, ' the Central Committee of the CPC has a lot of people to write about when you store it? No, if everybody writes, then it's going to take up a lot of memory. Because of the number of bytes, we can create a table to store these properties and then set the ID value of these attributes to bind the ID value to the person's table, and then save a lot of memory if the attribute is represented by the ID of the attribute. That's the foreign key. ,
Creation of foreign keys:
Create a foreign key when creating a table: Creating a table after the attribute table (parent table) is the one to bind the foreign key
Create within a table:
Constraint + FOREIGN key name +foreign key (ID of this table) +references parent table name (parent table ID column)
Must give you the name of the foreign key names of foreign keys in the same database cannot be the same
You can also create multiple foreign keys for the same table to create different foreign keys for different columns.
#被关联表create table class (id int auto_increment PRIMARY key, name varchar)ENGINE=INNODB default charset= UTF8; #关联表create table student (ID int auto_increment PRIMARY key, name varchar (+), class_id int, Constraint Fk_stu_class foreign key (ID) References class (ID)) engine=innodb default charset=UTF8; This is when creating the table at the same time the foreign key was created, constraint + foreign key name + foreign key + (the table to be associated with the column is usually the ID column) +references + parent table name (the ID column of the parent table)
The association of foreign keys must be two types that are the same type cannot be a bigint one is an int two columns should be the same type
MySQL additions and deletions to change the search