Reputation: 619
I'm trying to add a boolean column into an existing table
alter table chatuser add activerecord bool;
alter table chatuser add activerecord boolean;
where activerecord is my boolean column
Neither of these queries are working. How can I add a boolean column to an existing table?
Upvotes: 34
Views: 111280
Reputation: 2802
Add with default value
ALTER TABLE my_table ADD COLUMN new_field TinyInt(1) DEFAULT 0;
Upvotes: 14
Reputation: 5616
I found that on Microsoft SQL the following was invalid:
ALTER TABLE meTable ADD COLUMN someBoolCol TinyInt;
Omitting the "column" keyword worked:
ALTER TABLE meTable ADD someBoolCol TinyInt;
Upvotes: 2
Reputation: 8429
ALTER TABLE chatuser ADD activerecord BOOLEAN
No need of word 'column'
Your second query is perfectly all right (at least) in mysql.
Try:
select * from chatuser;
If you are unable to see results, check your mysql server or other things, not the
query and, if above select query works, and you do not have activerecord
named column already, I bet your query will work.
Upvotes: 2
Reputation: 263733
Lack COLUMN
keyword
ALTER TABLE ChatUser ADD COLUMN ActiveRecord TinyInt(1)
Upvotes: 17
Reputation: 204766
You have to define what you add - a column:
alter table chatuser add column activerecord bool;
Upvotes: 54