NULL vs DEFAULT NULL vs NULL DEFAULT NULL in MYSQL column creation?

前端 未结 2 753
孤独总比滥情好
孤独总比滥情好 2021-01-01 11:17

Following SQL table definition is illustrated one of create table statement from my MYSQL database which is developed by a former developer of my company.

DRO         


        
相关标签:
2条回答
  • 2021-01-01 11:52

    There is no difference. NULL DEFAULT NULL is the implicit default.

    From the CREATE TABLE documentation:

    • If neither NULL nor NOT NULL is specified, the column is treated as though NULL had been specified

    From the "Data Type Default Values" chapter:

    • If a column definition includes no explicit DEFAULT value, MySQL determines the default value as follows: If the column can take NULL as a value, the column is defined with an explicit DEFAULT NULL clause.
    0 讨论(0)
  • 2021-01-01 11:55

    In all three of the following cases:

    price DOUBLE NULL;
    
    price DOUBLE DEFAULT NULL;
    
    price DOUBLE NULL DEFAULT NULL;
    

    price is a double and can be null and its default value is null.

    0 讨论(0)
提交回复
热议问题