In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces mysql how to delete not null restrictions related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this mysql how to delete not null restrictions article will have a harvest, let's take a look.
In mysql, you can use the "ALTER TABLE" statement to remove the "not null" non-null restriction from the columns of the specified table, and use modify to modify the data types and constraints of the fields in the table. The syntax is "ALTER TABLE table name MODIFY field name INT NULL;".
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
How does mysql remove not null restrictions
We can use the ALTER TABLE statement to remove NOT NULL constraints from the columns of an existing table.
Modify is used to modify the data length, data type and field constraints of the fields in the table.
A MySQL non-null constraint (NOT NULL) means that the value of a field cannot be empty. For fields with non-null constraints, the database system will report an error if the user does not specify a value when adding data. This can be done through CREATE TABLE or ALTER TABLE statements. Add the keyword NOT NULL as a qualifier after the definition of a column in the table to constrain that the column cannot be empty.
For example, in the user information table, if the user name is not added, then the user information is invalid, and a non-empty constraint can be set for the user name field.
Example
Suppose we have a table "test123" with NOT NULL constraints on column "ID", as follows:
Mysql > DESCRIBE test123 +-+ | Field | Type | Null | Key | Default | Extra | +-+-+ | ID | int (11) | NO | | NULL | | Date | date | YES | | NULL | | +-+-+
Now, if we want to delete the NOT NULL constraint, we can use the ALTER TABLE statement, as follows:
The above result set indicates that the NOT NULL constraint on the column "ID" has been removed.
In the above query, the keyword NULL after the keyword MODIFY is optional. The following query will also produce the same results as above-
Mysql > ALTER TABLE test123 MODIFY ID INT;Records: 0 Duplicates: 0 Warnings: 0 this article on "how mysql removes not null restrictions" ends here. Thank you for reading! I believe you all have a certain understanding of "how mysql removes not null restrictions". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.