In this series, I will update some experimental reports that the teacher asked to write recently~
Please try to make a reference to my article, don’t blindly cv, after all, this is still very important for our future work and study.
Experiment content:
First, create three tables in the database: Employees (employee information table), Departments (department information table), Salary (employee salary table). Then complete the following operations
1. Use create index to create an index:
- Create a common index depart_index on the employee number column in the Employees table;
- Create a composite index ad_index on the name and address columns in the Employees table;
- Create a unique index on the Departmentname column in the Departments table;
- Use show index to see the indexes in the Employees table and Departments.
2. Use alter table to add index
- Add a unique index date_index to the birth time column in the Employees table, and add a composite index name_sex_index to the name and gender columns;
2) Create a primary key index for the department number in the Departments table;
3) Create a foreign key index on the department number column in the Employees table.
3. Create the index while creating the table
- Create cpk (product number, product name, unit price, inventory) (the data type and length of each column can be customized), and create a primary key for the product number column, and create a composite index cpk_fh_index in the inventory and unit price columns.
4. Display index
- Use show index to see the indexes on the Employees table
5. Delete the index
- Use drop index to delete the indexes depart_index, ad_index and date_index;
- Use alter table to drop the primary key and foreign key indexes on the Employees table.
6. Data integrity constraints
-
Create an employee bonus distribution table jj (employeid, je), where employeeid is the primary key, and its value must be the existing employee number in the Employees table, and when deleting and modifying the employee number column in the Employees table, the employee in the jj table is required The data in the numbered column also changes accordingly.
-
Create the employee table emp, only consider the 3 columns of employee number, name and gender, the name column satisfies the unique constraint, and the gender can only include male or female;
-
Create the employee table emp_1, only consider the 2 columns of employee number and birth time, require that the birth time must be greater than January 1, 1980, and name the constraint birthdate_id;
- Create the employee table emp_2, only consider the employee number and gender 2 columns, and confirm that all the values in gender come from the gender column of the emp table;
Subsequent experimental reports will be updated one after another. Please leave a message in the comment area if you don’t understand or make mistakes~
Your likes and attention are my biggest motivation for updating!