How to define the default values for a column when creating tables in MySQL?

swisscheese picture swisscheese · Apr 27, 2011 · Viewed 31.4k times · Source

What is the SQL to define DEFAULT values in MySQL?

In the code below what needs to be added / changed to give IsObsolete a default value of N?

CREATE TABLE Team
(
    TeamId              CHAR(16) NOT NULL,
    DateCreated          TIMESTAMP NOT NULL,
    IsObsolete           CHAR(1) NOT NULL DEFAULT N,
    UpdateTime           TIMESTAMP NOT NULL
);

Answer

Anthony Accioly picture Anthony Accioly · Apr 27, 2011
IsObsolete           CHAR(1) NOT NULL DEFAULT 'N'