douduoyan5943 2013-04-12 10:12
浏览 71
已采纳

在表格中添加列[重复]

This question already has an answer here:

I want to add a common column in all tables in a database

For example:

I want to insert the column TENANT_ID in all tables in database

How can i do that.

</div>
  • 写回答

2条回答 默认 最新

  • douchun1961 2013-04-12 10:34
    关注

    yes you can add it

    if you have list of table in array

    $column_name = 'TENANT_ID';
    $size = '';
    foreach($all_table_name as $each_table_name) {
       mysql_query("ALTER TABLE {$each_table_name} ADD {$column_name} VARBINARY({$size})");
    }
    

    above code i just skilton you have to set accourding to your code.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 android报错 brut.common.BrutException: could not exec (exit code = 1)
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!