0
I have a table in Postgresql with columns that are named "c0001", "c0992", "c3993", and so on. They start with c and then comes a "random number".
I have a dictionary in . csv explaining each of them and with a nickname. Ex:
Conta | Descricao | Apelido
c0001 | Valor disponível em caixa | Caixa
c0992 | Valor do Patrimônio Líquido | PL
... | .... | ...
To rename the column, use
ALTER TABLE schema.balanco RENAME c0001 TO Caixa
I need to do this for the 204 columns. Is there any way to do this without having to type one by one?
go to Notepad++, generate a macro, assemble the full script...
– Rovann Linhalis
You can open the file with any text editor that allows you to replace words with regular expression and have them replaced
\s+\|.*\|\s+forTOand then have them replace(spaces at the beginning of each line) byALTER TABLE schema.balanco RENAME.– Benilson