Cómo cambiar la definición de columna MySQL?
Tengo una tabla MySQL llamada test:
create table test(
locationExpect varchar(120) NOT NULL;
);
Quiero cambiar la columna locationExpect a:
create table test(
locationExpect varchar(120);
);
¿Cómo se puede hacer rápidamente?
132
Author: Eric Leschinski, 2009-10-20
3 answers
¿Te refieres a alterar la tabla después de que haya sido creada? Si es así, debe usar alter table , en particular:
ALTER TABLE tablename MODIFY COLUMN new-column-definition
Por ejemplo
ALTER TABLE test MODIFY COLUMN locationExpect VARCHAR(120);
237
Author: mikej,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-26 16:45:52
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-26 16:45:52
Sintaxis para cambiar el nombre de la columna en MySQL :
alter table table_name change old_column_name new_column_name data_type(size);
Ejemplo:
alter table test change LowSal Low_Sal integer(4);
41
Author: Niranjan Vaddi,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-01-02 09:20:52
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-01-02 09:20:52
Esto debería hacerlo:
ALTER TABLE test MODIFY locationExpert VARCHAR(120)
11
Author: Daniel Rikowski,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-10-20 15:19:22
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-10-20 15:19:22