ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [Table Copy] MySQL / MSSQL / Oracle - Table 복사
    db 2022. 7. 12. 19:30

    1. MySQL

        1)  Only Table Structure (Data X) - 테이블 구조만 복사 (데이터 X)

    Create table @schma_name.@target_Table like @schma_name.@source_Table
    
    [Example]
    Create table unick_db.map3 like unick_db.map

      

       2) Table Structure + Data Copy (All Copy) - 테이블 구조 + 데이터 복사 (전체 복사)     

    Create table @schma_name.@target_Table select * from @schma_name.@source_Table
    
    [Example]
    Create table unick_db.map3 select * from unick_db.map

          

    [샘플 실행 화면]

    2. MSSQL

        1)  Only Table Structure (Data X) - 테이블 구조만 복사 (데이터 X) 

    select * into @target_table from @source_table where 1=2
    
    [Example]
    select * into map2 from map where 1=2
    -- Defferent Database
    select * into EMS..map2 from Smart7..map where 1=2

     

       2) Table Structure + Data Copy (All Copy) - 테이블 구조 + 데이터 복사 (전체 복사)     

    SELECT * INTO @target_table FROM @source_table
    
    [Example]
    select * into map2 from map
    --Defferent database
    select * into EMS..map2 from Smart7..map

     

    2. Oracle

        1)  Only Table Structure (Data X) - 테이블 구조만 복사 (데이터 X) 

    Create table @target_table as select * from @source_table where 1=2
    
    [Example]
    Create table map2 as select * from map where 1=2

       2) Table Structure + Data Copy (All Copy) - 테이블 구조 + 데이터 복사 (전체 복사)  

    Create table @target_table as select * from @source_table
    
    [Example]
    Create table map2 as select * from map

     

    댓글

Designed by Tistory.