473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to alter or change column with ALTER TABLE

I would like to change the type of Null to NO ,what is the command for this?
I've tried this one, but no luck to get it work.
ALTER TABLE claims_summary ALTER COLUMN advance_call_details SET NOT NULL;

Thanks.
Terence
+----------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+--------------+------+-----+---------+-------+
| client_id | int(11) | | | 0 | |
| client_code | varchar(30) | | PRI | | |
| club_id | int(11) | | | 0 | |
| club_code | varchar(30) | | PRI | | |
| yearclaim | int(10) | | PRI | 0 | |
| advance_call | double(16,4) | YES | | 0.0000 | |
| additional_call | double(16,4) | YES | | 0.0000 | |
| supplementary_call | double(16,4) | YES | | 0.0000 | |
| release_call | double(16,4) | YES | | 0.0000 | |
| advance_call_details | varchar(240) | YES | | | |
+----------------------+--------------+------+-----+---------+-------+
May 14 '07 #1
6 12194
tashy
10
Try this ALTER TABLE table name ALTER COLUMN column name data type NOT NULL


By data type ,it could either be int,bit,etc
May 14 '07 #2
pbmods
5,821 Expert 4TB
When you change or alter a column, you are basically redefining it, so you have to provide a full definition of the column, not just the attributes you want to change (otherwise, how would MySQL know if you wanted to remove an attribute from a column?).

P.S., Please surround your mysql output with CODE tags to make it easier to read next time. Thanks.
May 15 '07 #3
Thanks a lot
, I'v tried, but it return the following errors at the end. Is it possible to define the datetype : varchar(240) ?

mysql> ALTER TABLE claims_summary ALTER COLUMN advance_call_details varchar(240) NOT NULL;

ERROR 1064: You have an error in your SQL syntax near 'varchar(240) NOT NULL' at line 1
May 15 '07 #4
pradeep kaltari
102 Expert 100+
Thanks a lot
, I'v tried, but it return the following errors at the end. Is it possible to define the datetype : varchar(240) ?

mysql> ALTER TABLE claims_summary ALTER COLUMN advance_call_details varchar(240) NOT NULL;

ERROR 1064: You have an error in your SQL syntax near 'varchar(240) NOT NULL' at line 1
Hi,
Try this:
Expand|Select|Wrap|Line Numbers
  1. ALTER TABLE table_name MODIFY COLUMN column_name VARCHAR(240) NOT NULL
  2.  
Regards,
Pradeep
May 15 '07 #5
Atli
5,058 Expert 4TB
Hi.

If you also want to change the name of the column you can do this:
Expand|Select|Wrap|Line Numbers
  1. ALTER TABLE myTable
  2. CHANGE myCol 
  3.   newName dataType NOT NULL;
  4.  
May 15 '07 #6
Thank you so much. It's very useful tips..
May 15 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lannsjo | last post by:
I need to change my primary key column type from smallint to int. I have tried: ALTER TABLE livegroup MODIFY id INT UNSIGNED NOT NULL AUTO_INCREMENT; But get an error message certainly since my...
1
by: Bruce | last post by:
Hi, I want to change the datatype of an existing column from char to varbinary. When I run the "Alter Table" statement, I get the following error message - Disallowed implicit conversion...
1
by: Danny | last post by:
I'm trying to simply change a column definition from Null to Not Null. It's a multi million row table. I've already checked to make sure there are no nulls for any rows and a default has been...
10
by: Jane | last post by:
Does any one know why this statement is failing? db2 => ALTER TABLE ELMT_T ALTER COLUMN CDTY_CD SET DATA TYPE VARCHAR(51) DB21034E The command was processed as an SQL statement because it was...
3
by: Darin | last post by:
I have many columns in different tables set to money. I want to change those to be decimal(18,2). I do the following: ALTER TABLE AROpenItem ALTER COLUMN copn_taxamt decimal(19,2) I get an...
5
by: minjie | last post by:
Is it possible to run a simple script to alter a table column in Access database from an interger to a double? I have been writing C++ programs every time we need to upgrade (modify) the Access...
4
by: Jeff Kish | last post by:
Hi. I have a database I need to supply something (I'm assuming a t-sql script.. maybe something else is better) to update customer tables with. The operations include mostly changing varchar...
2
by: RamaKrishna Narla | last post by:
In MS SQL Server, I have the following tables with some data in it. create table table1 ( column1 varchar(32), column2 int not null, column10 varchar(255), ..... primary key (column1,...
7
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get...
1
by: vasilip | last post by:
I'm testing out db2 for a project I'm starting that requires proper xml support and I can't seem to get both xml and spatial data to work well in the same table. Once having created a table...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.