Home > Database > Mysql Tutorial > body text

mysql表之间的复制,同数据库和不同数据库_MySQL

WBOY
Release: 2016-06-01 13:01:04
Original
1150 people have browsed it

Mysql的语句

我们可以先把test下的t1表的结构导出来,然后新建立一个test1.t1表。

执行下面语句

insert into test1.t1 select * from test.t1 limit 2 (limit限制条数)

如果在一个数据库中就是



insert into t1 select * from t2 limit 2

如果表结构不一样的两张表,可以考虑、、参考下面的语句

 

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 
Copy after login

 

 

insert into test1.t1 select * from test.t1 limit 2
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template