Nika
Nika

Reputation: 379

Automatically change the name of column everywhere with the renaming the name of column

I need to change my column name in mysql and I want to automatically update all triggers, procedures, functions where that name is used to new name. How can I do this?

I tried this syntax but it doesn't effect to my funcs, proc etc.

ALTER TABLE t1 CHANGE col1 col2 double;

Upvotes: 0

Views: 136

Answers (1)

Jonatas
Jonatas

Reputation: 108

There is no way of changing a column name and automatically updating all referenced objects.

Your best option is to query objects using information_schema tables and change them.

For example, to query stored procedures and user defined functions that its definition has reference to col1:

SELECT * FROM information_schema.routines WHERE routine_definition LIKE '%col1%'

information_schema reference

Upvotes: 1

Related Questions