I want to rename the column via SQL. I'm trying this way:
ALTER TABLE nomes_clientes
RENAME COLUMN primeiro_nome TO nome,
RENAME COLUMN segundo_nome TO sobrenome;
But that way it is not working.
I want to rename the column via SQL. I'm trying this way:
ALTER TABLE nomes_clientes
RENAME COLUMN primeiro_nome TO nome,
RENAME COLUMN segundo_nome TO sobrenome;
But that way it is not working.
I want to rename the column via SQL. I'm trying this way:
ALTER TABLE nomes_clientes
CHANGE primeiro_nome nome VARCHAR(255) NOT NULL;
CHANGE segundo_nome sobrenome VARCHAR(255) NOT NULL;
But that way it is not working.
You need to reset every column as follows:
ALTER TABLE nomes_clientes
CHANGE primeiro_nome nome VARCHAR(255) NOT NULL;
CHANGE segundo_nome sobrenome VARCHAR(255) NOT NULL;
Just as @bigown commented will depend on the database you are using, but for these three (Oracle, PostgreSQL and MySQL) it is as follows:
Oracle
%pre%PostgreSQL
%pre%MySQL
%pre%References: MySQL | PostgreSQL Oracle
Complementing the answer:
SQLServer
%pre%In this bank, a ready sp is used. Remember that you must use %code% to execute the procedure. The third parameter 'COLUMN' is required for the case in question, which is to rename a column. Example:
%pre%For more details on using SP:
References: SQLServer
Just as @bigown commented will depend on the database you are using, but for these three (Oracle, PostgreSQL and MySQL) it is as follows:
Oracle
ALTER TABLE T_CLASSE_SOCIAL
RENAME COLUMN TESTE TO TESTE_NOVO;
PostgreSQL
ALTER TABLE distribuidores RENAME COLUMN endereco TO cidade;
MySQL
ALTER TABLE tabela_exemplo CHANGE id_exemplo novo_id_exemplo integer(5) unsigned;
References: MySQL | PostgreSQL Oracle
Complementing the answer:
SQLServer
sp_RENAME '[Tabela.NomeColuna]', '[NovoNomeColuna]' , 'COLUMN'
In this bank, a ready sp is used. Remember that you must use exec
to execute the procedure. The third parameter 'COLUMN' is required for the case in question, which is to rename a column. Example:
exec sp_RENAME
'Pessoa.codPessoa',
'codPessoaAlterada',
'COLUMN'
For more details on using SP:
References: SQLServer