开发者

I want to change comment using query in phpMyAdmin

I have a table called phase with following fields. ID,Name. I want to change its comment using query.

ALTER TABLE phase 
CHANGE Name Name VARCHAR(200) CHARACTER SET latin1 COLLATE 开发者_开发技巧latin1_swedish_ci NULL  COMMENT Hello world

But its not useful for me as i wont be able to generate similar query from my php application. Help needed....


Try:

ALTER TABLE `phase` CHANGE `Name` `Name` VARCHAR(200) CHARACTER SET COLLATE latin1_swedish_ci NULL COMMENT 'comment here...'

Update

Try this, in your PHP application:

$result = mysql_query('DESC `phase`');
if(is_resource($result) && mysql_num_rows($result) > 0){
    while($column =  mysql_fetch_assoc($result)){
        if($column['Field'] === 'Name'){
            $comment_query = "ALTER TABLE `phase` CHANGE `{$column['Field']}` `{$column['Field']}` {$column['Type']} CHARACTER SET COLLATE latin1_swedish_ci {$column['Default']} COMMENT 'comment here...'";
            $result = mysql_query($comment_query);
            echo ($result) ? 'Added comment' : 'Failed to add comment';
            break;
        }
    }
} else{
    echo 'Not a table description result';
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜