Page 1 of 1
how to affect each colmn in every table(mysql)
Posted: Thu Oct 19, 2006 10:20 am
by g_alex_stef
Hello people,
i am wondering if there is any script or class that can affect every column in all tables of a database
unfortunately my knoledge yet in mysql is pour so i cant write it by myself even though i imagine it might be too easy.
if someone knows any class or can write one for me i would apreciate it.
Posted: Thu Oct 19, 2006 10:46 am
by feyd
what are you trying to do with this?
Posted: Thu Oct 19, 2006 10:54 am
by g_alex_stef
i need to change the collation in every single column and this is the only way i have figure out until now.
i will use the following queries:
Code: Select all
ALTER TABLE table MODIFY column BINARY(n);
ALTER TABLE table MODIFY column CHAR(n) CHARACTER SET greek
but instead of table i must insert a variable which is generated in a loop i suppose the problem is i dont know mqsql at all....
i could that manually but my db is too big
thanks for showing interest

Posted: Thu Oct 19, 2006 11:29 am
by Weirdan
Actually you don't want it to affect every column in every table, do you? What would it do to integer or date columns?
Posted: Thu Oct 19, 2006 4:19 pm
by g_alex_stef
well i suppose that an "if" statement would solve that problem, a fuction whith an if statement affecting only char(), varchar() and text, i have no tinytext etc types on my db
to be more prescise for example:
Code: Select all
function choosetype(curent_table,current_column,new_type,old_type) {
if type of current table current_column is char() then
new_type=bin()
old_type=char()
end if
if type of current table current_column is varchar() then
new_type=varbin()
old_type=varchar()
end if
if type of current table current_column is text then
new_type=Blob
old_type=text
end if
}
loop tables{
loop columns{
function(table,column,newtype,oldtype)
ALTER TABLE table MODIFY column newtype;
ALTER TABLE table MODIFY column oldtype CHARACTER SET greek
}
}
***something very important is the length of every column ****
i hope you can understand what i am looking for
but i need that in php!!!!!

i dont know php neither mysql...............
Posted: Thu Oct 19, 2006 6:44 pm
by Weirdan