Search code examples
mysqlnullcreate-table

Default NULL entry in MySQL table


Not a duplicate of MySQL dud entry in table, since I have no gaps in my id column and inserting did not resolve it.

I have a table with the following schema, but there is a default entry is created with NULL in all the columns. This NULL row is returned for every select query even if I add "film_id IS NOT NULL" as a clause.

CREATE TABLE film(
    film_id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
    film_title VARCHAR(100) NOT NULL,
    film_release_year YEAR NOT NULL
);

The output of "select * from film"

table value with NULL entry

The output of "select * from film where film_id = 27" note:film_id is a primary key.

enter image description here

I get the NULL entry for all select statements. I can see it since the table is created.


Solution

  • I believe that's just a quirk of MySQL Workbench that lets you insert rows if you click those NULL squares and enter values there. That row doesn't exist in your table.