SQL: how to change this value

Hi experts,

I have a table as follows.

mysql> desc message_alert  ;
+---------------+-------------+------+-----+---------+----------------+
| Field             | Type        | Null | Key | Default | Extra          |
+---------------+-------------+------+-----+---------+----------------+
| id                | int(11)     | NO   | PRI | NULL    | auto_increment |
| dataset_id  | int(11)     | YES  | MUL | NULL    |                |
| dimension1 | varchar(20) | NO   |     | NULL    |                |


Now I want to change the value of column "Null" for "dataset_id" to "NO".  any ideas how to write this SQL?

Thanks so much.
davidw88Asked:
Who is Participating?
 
mrjoltcolaConnect With a Mentor Commented:
Try MODIFY

ALTER TABLE message_alert MODIFY COLUMN dataset_id int(11) NOT NULL;
0
 
pssandhuCommented:
ALTER TABLE message_alert
ALTER COLUMN dataset_id int(11) NOT NULL
 
0
 
pssandhuCommented:
Oh, I answered based on the MySQL.... since your desc statement says mysql
P.
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
mrjoltcolaCommented:
Are you asking how to change the default value for the column? If so, you cannot set it to 'NO' because the column is an integer type.

In any case, it is unclear which database you are referring to, your sample shows MySQL but you posted in Oracle and SQL Server zones.
0
 
davidw88Author Commented:
This is MySQL.

Hi pssandhu: thanks so much for your prompt reply. I got

mysql> ALTER TABLE message_alert ALTER COLUMN dataset_id int(11) NOT NULL;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'int(11) NOT NULL' at line 1


any more ideas?

0
 
pssandhuCommented:
What version of MySQL are you running. I am not too familiar wiht all different versions, but there might be a limitation based on your MySQL product version.
P.
0
 
pssandhuConnect With a Mentor Commented:
You might need to use the Change or Modify key words. Please see here:
http://www.freeopenbook.com/mysqlcookbook/mysqlckbk-chp-8-sect-3.html
P.
0
 
davidw88Author Commented:
It is Server version: 5.0.67-0ubuntu6 (Ubuntu)
0
 
davidw88Author Commented:
Cool! mrjoltcola's sql works!

Thanks experts!
0
 
davidw88Author Commented:
Thanks Advisor mrjoltcola for your advice. I did try to post in "MySQL" Zone, however I did not find such a zone so I posted in other related zones.
0
All Courses

From novice to tech pro — start learning today.