// create instance of CDbCommand class
$command = Yii::app()->db->createCommand();
// create query and run it to select appropriate number from your table
$no = $command->select('sno')
->from('table_name')
->order('sno desc')
->queryScalar();
// merge the prefix and the number
$col_name = 'P'.$no;
// if you want to rename the current column use this code
$command->renameColumn('table_name', 'id', $col_name);
// if you want to add new column use this code
$command->addColumn('table_name', $col_name, 'varchar(20)');