Select Database
Create a data table
Include field name and data type two parts
View Data Sheet
Using PRIMARY KEY constraints
The primary key is also called the main code, can be a unique representation of a record in the table, divided into single Chini and multi-field joint primary key
Single Field primary key
There are two ways to define a primary key:
1. Specify the primary key at the end
2. Identify after the primary key line
Multi-field Federated primary key
No ID, combine two fields to master key
using FOREIGN KEY constraints
Foreign keys are used to establish a connection between data in two tables, which can be one or more columns. A table can have one or more foreign keys.
The foreign key is first a field in its table, which may not be the primary key for the table, but the primary key for the other table
For example, the primary key for a departmental table is ID, and there is a key in the employee table that is related to this ID
Example: Defining a data table TB_EMP5 and creating a FOREIGN key constraint on a table
Define the data table TB_EMP5 let its key deptid be associated with the TB_DEPT1 's primary key ID as a foreign key.
Association refers to the relation between related tables in a relational database. He is represented by the same attribute or group of attributes. The foreign key of the child table must be associated with the primary key of the parent table, and the data type of the associated field must match.
Using non-null constraints
Field name The field type is not null,
Indicates that its insertion value cannot be null
Using Uniqueness constraints
Requires the column to be unique, allowed to be empty, but only one null value appears
Using Default Constraints
Specify the default value for a column
View the data table structure
Describe
Desc Table name
Show CREATE TABLE
Setting the property value of a table automatically increases
For example, let the ID automatically increase by 1
For example, execute an INSERT statement and query
Modify the data table name
MySQL Learning--Data sheet basic Operation 1