MySQL中判斷表是否存在:
1. SHOW TABLES LIKE '%tb_bp_d_case%';
2. select `TABLE_NAME` from `INFORMATION_SCHEMA`.`TABLES` where `TABLE_SCHEMA`='dbname' and `TABLE_NAME`='tablename' ;
3. 如果表不存在就建立這個表,那么可以直接用 create table if not exists tablename 這樣的指令來建立,不需要先去查詢表是否存在。
4. 從模板表創建表:create table if not exists like old_table_name;
文章出處:DIY部落(http://www.diybl.com/course/7_databases/mysql/Mysqljs/20090313/161045.html)
posted on 2010-01-08 20:22
SINOJAVA 閱讀(2147)
評論(0) 編輯 收藏 所屬分類:
MySQL