Any explanation for this SQL?

-1
$alters = " ALTER TABLE imovel
  MODIFY COLUMN ENDERECO VARCHAR(150),
  MODIFY COLUMN BAIRRO VARCHAR(150)";
$pdo->exec($alters);

As I lower the value of varchar, it will update, but if I increase the value of varchar it does not work anymore.

Any explanation?

    
asked by anonymous 26.12.2014 / 19:16

1 answer

1

You can join all MODIFY:

ALTER TABLE imovel
  MODIFY (ENDERECO VARCHAR(150),
          BAIRRO VARCHAR(150)
          );

I do not know if MySQL is compatible with the above!

But you can also remove the "COLUMN" parameter for MySQL:

ALTER TABLE imovel
  MODIFY ENDERECO VARCHAR(150),
  MODIFY BAIRRO VARCHAR(150);

As far as you know, the only one with " [FUNÇÃO] COLUMN nome_da_coluna " is DROP , this is " DROP COLUMN ".

However, everything else is MODIFY nome_da_coluna and ADD nome_da_coluna , not including COLUMN in the function name.

    
26.12.2014 / 19:20