Reputation: 653
I want to modify the table users adding the column crypto
Trying to execute this query but I'm getting an error:
ALTER TABLE `users` ADD COLUMN `crypto` VARCHAR(255) NULL '{"bitcoin": 0, "ethereum": 0, "bitcoin-cash": 0, "bitcoin-sv": 0, "litecoin": 0, "binance-coin": 0, "monero": 0, "dash": 0, "zcash": 0, "maker": 0}';
This is the error: You have an error in your SQL syntax
If I try to create the column manually and setting the default values I get the same error.
Upvotes: 0
Views: 611
Reputation: 2307
You just forget DEFAULT
in your query:
ALTER TABLE `users` ADD COLUMN `crypto` VARCHAR(255) NULL DEFAULT '{"bitcoin": 0, "ethereum": 0, "bitcoin-cash": 0, "bitcoin-sv": 0, "litecoin": 0, "binance-coin": 0, "monero": 0, "dash": 0, "zcash": 0, "maker": 0}';
Upvotes: 0
Reputation: 562368
Declare a column DEFAULT value with the DEFAULT
keyword.
ALTER TABLE `users` ADD COLUMN `crypto` VARCHAR(255) NULL DEFAULT '{"bitcoin": 0, "ethereum": 0, "bitcoin-cash": 0, "bitcoin-sv": 0, "litecoin": 0, "binance-coin": 0, "monero": 0, "dash": 0, "zcash": 0, "maker": 0}';
Upvotes: 1