如何用 Insert Into 生成一个新表,如果表不存在,就自动创建它,如何做?

解决方案 »

  1.   

    select * into newTableName  from oldTableName where  .....
      

  2.   

    select *  into newTableNaem
    from
    (
    select 1 , '01'
    union select 2 , '02'
    union select 3 , '03'
    union select 4 , '01'
    union select 5 , '02'
    union select 6 , '03'
    union select 7 , '01'
    union select 8 , '02'
    union select 9 , '04'
    union select 10 , '05'
    )
      

  3.   

    --如果接受数据导入的表已经存在
    insert into 表 select * from tablename
    --如果导入数据并生成表
    select * into 表 from tablename
      

  4.   

    select * into newTableName  from oldTableName
      

  5.   

    Insert Into 生成一个新表不行,要用select Into
      

  6.   

    MD. 我用的 FireBird 不支持 Select into
      

  7.   

    if(表存在)
    begin
       insert 表名 select ...
    end
    else
    begin
       create table 表名
       insert 表名 select ...
    endg
      

  8.   

    if(表存在)
    begin
       insert 表名 select ...
    end
    else
    begin
       create table 表名
       insert 表名 select ...
    endg
      

  9.   

    if exists
      (select table_name from information_schema where table_name='tabname')---判断表是否存在
    drop table tabname
    else
     begin
     create table tabname
     insert tabname 
     select [被导入的表]
     where condition
    end