Solved

SQL: how to change this value

Posted on 2009-07-10
13
240 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-sql Date Format 9 67
UPDATE JOIN multiple tables 5 35
SQL Server how to create a DYNAMIC TABLE? 11 51
Ordering displaying data in a drop down 3 10
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 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