Bug #37190 It is not possible to define a NULL timestamp column

Submitted: 4 Jun 2008 10:54 Modified: 5 Jun 2008 8:03
Reporter: Daniel Haas Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:5.0.22 OS:Windows (Vista)
Assigned to: CPU Architecture:Any

[4 Jun 2008 10:54] Daniel Haas
Description:
Since MySQL 5.0 it is possible to declare timestamp-columns to contain the value NULL. (See http://dev.mysql.com/doc/refman/5.0/en/timestamp.html)

However in MySQL Workbench it is not possible to define such a column in a table, because there are no options to do so. 

How to repeat:
Create a Column with timestamp type and try to define that this columns is NULLable.

Suggested fix:
The Flags-Box on the right in the table columns-editor should provide a checkbox "NULL" when the type of the column is TIMESTAMP. This should then add the NULL Flag to the SQL-Create for the table/column.
[4 Jun 2008 16:46] Valeriy Kravchuk
Just do not check NN checkbox for TIMESTAMP column and you'll get something like (I had exported CREATE script from 5.0.22):

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';

CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `mydb`;

-- -----------------------------------------------------
-- Table `mydb`.`table1`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`table1` (
  `idtable1` INT NOT NULL ,
  `c1` VARCHAR(45) NULL ,
  `c2` TIMESTAMP NULL ,
  PRIMARY KEY (`idtable1`) )
ENGINE = InnoDB;

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

So, what is the problem?
[5 Jun 2008 8:03] Daniel Haas
Ah, so I think the problem is that I did not understand that not clicking the NN column adds an explicit NULL to the table definition. Sorry I must have overlooked that. :-)

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.053 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.