1. 程式人生 > >mysql表與表之間資料的轉移

mysql表與表之間資料的轉移

1.相同表結構

INSERT INTO table1 SELECT * FROM table2;

2.不同表結構

INSERT INTO table1(filed1,...,filedn) SELECT table2.filed1,...,table2.filedn FROM table2;

3.如果是不同資料庫之間,參考以下:

INSERT into db_ds_edu.t_exam_student(stu_id,stu_number,stu_name,school_id,campus_id,grade_id,class_id,xuebu_id) 
  SELECT stu.id 
     , stu.student_num 
    ,person.name 
     , stu.school_id 
     , stu.campus_id 
     , stu.grade_id 
     , stu.clas_id 
     , stu.xuebu_id 
FROM 
  db_ds.t_stu_info AS stu 
    ,db_ds.t_p_person_info as person 
    WHERE stu.person_id = person.id 
---------------------
作者:清無時空
來源:CSDN
原文:https://blog.csdn.net/sinat_34439107/article/details/70214335
版權宣告:本文為博主原創文章,轉載請附上博文連結!