Solved

SQL: how to change this value

Posted on 2009-07-10
13
239 Views
Last Modified: 2012-05-07
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.
0
Comment
Question by:davidw88
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
13 Comments
 
LVL 17

Expert Comment

by:pssandhu
ID: 24826556
ALTER TABLE message_alert
ALTER COLUMN dataset_id int(11) NOT NULL
 
0
 
LVL 17

Expert Comment

by:pssandhu
ID: 24826569
Oh, I answered based on the MySQL.... since your desc statement says mysql
P.
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24826684
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:davidw88
ID: 24826691
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
 
LVL 17

Expert Comment

by:pssandhu
ID: 24826708
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
 
LVL 17

Assisted Solution

by:pssandhu
pssandhu earned 60 total points
ID: 24826745
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
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 65 total points
ID: 24826771
Try MODIFY

ALTER TABLE message_alert MODIFY COLUMN dataset_id int(11) NOT NULL;
0
 

Author Comment

by:davidw88
ID: 24826789
It is Server version: 5.0.67-0ubuntu6 (Ubuntu)
0
 

Author Comment

by:davidw88
ID: 24826804
Cool! mrjoltcola's sql works!

Thanks experts!
0
 

Author Comment

by:davidw88
ID: 24826818
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question