Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can solve this task by building a script, starting with the output from this statement:</p> <pre><code>SELECT table_name, column_name, data_type FROM information_schema.columns WHERE table_schema = 'dbname'; ORDER BY table_name </code></pre> <p>Details about this feature can be found here "<a href="http://dev.mysql.com/doc/refman/5.0/en/columns-table.html" rel="nofollow noreferrer">MYSQL::The INFORMATION_SCHEMA COLUMNS Table</a>"</p> <p>Then you can use the ALTER TABLE .. CHANGE feature to change the name of the columns</p> <p>e.g.</p> <pre><code>ALTER TABLE mytable CHANGE old_name new_name varchar(5); </code></pre> <p>See also "<a href="http://dev.mysql.com/doc/refman/5.1/en/alter-table.html" rel="nofollow noreferrer">MYSQL::ALTER TABLE Syntax</a>"</p> <p>Different datatype have different requirements so you need the UNIONs:</p> <pre><code>SELECT 'ALTER TABLE '||table_name||' CHANGE '|| column_name||' '||lower(column_name)||' '||datatype||'('||CHAR(character_maximum_length)||');' AS Line FROM information_schema.columns WHERE table_schema = dbname and datatype in ( 'CHAR', 'VARCHAR' ) ORDER BY table_name UNION SELECT 'ALTER TABLE '||table_name||' CHANGE '|| column_name||' '||lower(column_name)||' '||datatype||'('||CHAR(numeric_precision)||');' AS Line FROM information_schema.columns WHERE table_schema = dbname and datatype in ( 'INTEGER' ) ORDER BY table_name UNION SELECT 'ALTER TABLE '||table_name||' CHANGE '|| column_name||' '||lower(column_name)||' '||datatype||'('||CHAR(numeric_precision)||','||CHAR(numeric_scale)|');' AS Line FROM information_schema.columns WHERE table_schema = dbname and datatype in ( 'FLOAT' ) ORDER BY table_name UNION SELECT 'ALTER TABLE '||table_name||' CHANGE '|| column_name||' '||lower(column_name)||' '||datatype||');' AS Line FROM information_schema.columns WHERE table_schema = dbname and datatype in ( 'DATE' ) ORDER BY table_name </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload