Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to alter table column data type [closed]

Tags:

mysql

I've the following column

hits text NOT NULL

and want to alter it to

hits bigint(20) unsigned NOT NULL default '0'

how to use ALTER TABLE commands to do this change ! ~ thanks

like image 769
Reham Fahmy Avatar asked Oct 17 '12 10:10

Reham Fahmy


People also ask

How do you change the datatype of a column with data?

Change data types in Datasheet view Select the field (the column) that you want to change. On the Fields tab, in the Properties group, click the arrow in the drop-down list next to Data Type, and then select a data type. Save your changes.

Is it possible to modify a datatype of a column when column contains data?

You can modify the data type of a column in SQL Server by using SQL Server Management Studio or Transact-SQL. Modifying the data type of a column that already contains data can result in the permanent loss of data when the existing data is converted to the new type.

What command is recommended to alter the data type of a column?

The ALTER COLUMN command is used to change the data type of a column in a table.


1 Answers

ALTER TABLE table_name MODIFY hits bigint(20) unsigned NOT NULL default '0';
like image 83
PyQL Avatar answered Nov 08 '22 18:11

PyQL