arrow_backwardBack to MySQL code examples

MySQL Alter Column Default Example

How to change a column's default value in MySQL
A common example for a created_at column - setting the default to the time that the record was created
ALTER TABLE
  `users`
ALTER COLUMN
  `created_at`
SET
  DEFAULT CURRENT_TIMESTAMP
Making the default value static
ALTER TABLE
  `users`
ALTER COLUMN
  `first_name`
SET
  DEFAULT 'Mateo'

Using Beekeeper Studio?

Beekeeper Studio is a free and open source database manager for Windows, Mac, and Linux.

This feature is baked right in, so there's no need to manually type SQL every time. Access column editing by right-clicking on a table in the sidebar and clicking 'View Structure'.

Download Beekeeper Studio