Modifying MySQL Database Table Constraints

Beginner

In this project, you will learn how to modify the `countrylanguage` table in a MySQL database by removing the 'not null' constraint from the `IsOfficial` field.

SQLMySQL

Introduction

In this project, you will learn how to modify the countrylanguage table in a MySQL database by removing the "not null" constraint from the IsOfficial field.

👀 Preview

MariaDB [world]> DESC countrylanguage;
+-------------+---------------+------+-----+---------+-------+
| Field       | Type          | Null | Key | Default | Extra |
+-------------+---------------+------+-----+---------+-------+
| CountryCode | char(3)       | NO   | PRI |         |       |
| Language    | char(30)      | NO   | PRI |         |       |
| IsOfficial  | enum('T','F') | YES  |     | NULL    |       |
| Percentage  | decimal(4,1)  | NO   |     | 0.0     |       |
+-------------+---------------+------+-----+---------+-------+
4 rows in set (0.002 sec)

🎯 Tasks

In this project, you will learn:

  • How to start the MySQL database and access it using the sudo command
  • How to import the world.sql data file into the MySQL database
  • How to modify the countrylanguage table by removing the "not null" constraint from the IsOfficial field
  • How to verify the changes made to the countrylanguage table

🏆 Achievements

After completing this project, you will be able to:

  • Understand how to work with MySQL databases using the command-line interface
  • Modify table structures by altering the constraints on fields
  • Verify the changes made to a table by describing its structure

Teacher

labby

Labby

Labby is the LabEx teacher.