mysql怎样实现“ 如果表存在则清空,不存在则创建临时表”
帮我一下大家!

解决方案 »

  1.   

    CREATE TABLE IF NOT EXISTS TB(ID INT);
    TRUNCATE TABLE TB;
    不要弄得那么严格,不存在表创建,然后不管是新建的,还是之前主存在的,都 TRUNCATE 就行了(反正新建的表也不会有数据,TRUNCATE 不影响最终结果)
      

  2.   

    drop table if exists t_user;
    create table if not exists t_user(
       id   int(11) primary key auto_increment,
       name varchar(50) not null,);