- Explore
- Collaborate
- Visualize
- Connect
- Pricing
How to Add a Default Value to a Column in MySQL
To add a default value to a column in MySQL, use the ALTER TABLE ... ALTER ... SET DEFAULT
command:
--Example: Products have a default stock of 0
ALTER TABLE products ALTER COLUMN stocks integer SET DEFAULT 0;
--Example: Products are available by default (removed optional COLUMN keyword)
ALTER TABLE products ALTER available SET DEFAULT true;
Shared queries and folders ✅ Version history ✅ One-click connection to MySQL ✅
Get more done, together, with PopSQL and MySQL
Shared queries and folders ✅ Version history ✅ One-click connection to MySQL ✅
Get more done, together, with PopSQL and MySQL