Column default value is None

Asked 1 years ago, Updated 1 years ago, 69 views

What do you want to do in the end
Except for NULL, I only want to extract columns with "no default value"

Q1.phpMyAdmin shows no default value, what does that mean? I would like to know how "no default" is handled internally.

After executing the following command, the column "NOT NULL with no default value" was displayed as "Default NULL."

show columns from table name;

The Default field indicates the default value assigned to this column.The explicit default value for this column is NULL
If the column definition does not contain a DEFAULT clause, this is NULL.

Show COLUMNS syntax

"If the column definition does not contain a DEFAULT clause, this is NULL" means which of the following?

  • None default value and NULL mean the same
  • No default value and NULL have different meanings, but the results of SHOW COLUMNS are the same

Q2. Where can I find the information "NOT NULL with no default value" and "Do you have a NOT NULL constraint set?"
for the column? I thought it was in INFORMATION_SCHEMA.COLUMNS, so I tried the SQL below, but I didn't understand it well

select*from`INFORMATION_SCHEMA`.`COLUMNS`where`TABLE_SCHEMA`='Table Name'

mysql

2022-09-30 21:40

1 Answers

MySQL probably thinks that the default value is NULL and that the default value is not specified are equivalent.

Q2. Where can I find "NOT NULL with or without default values" and "Do you have NOT NULL constraints set?"

for columns?

select IS_NULLABLE, COLUMN_DEFAULT from information_schema.columns where table_schema='table name';

represents NUNULL allowed 「 and カラムColumn default values.In other words, IS_NULLABLE is NO.


2022-09-30 21:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.