0

hypothesis database(mysql) have the following data:

  +----+----------+------------+---------+------+------+------+
  | id | username | birthday   | address | age  | mid  | lid  |
  +----+----------+------------+---------+------+------+------+
  |  1 | tom      | 1536154211 | abc     |   19 | NULL |    1 |
  |  2 | Jan      | 1536154211 | bdb     |   12 | NULL |    2 |
  |  3 | Xu       | 1536154211 | aaa     |   11 | NULL |    3 |
  +----+----------+------------+---------+------+------+------+

How do I convert the data in the table like this statement:

 INSERT INTO `tb_user` VALUES (1, 'tom', 1536154211, 'abc', 19, NULL, 1);
 INSERT INTO `tb_user` VALUES (2, 'Jan', 1536154211, 'bdb', 12, NULL, 2);
 INSERT INTO `tb_user` VALUES (3, 'Xu', 1536154211, 'aaa', 11, NULL, 3);

What do the JDBC or mysql how to do this

songzeyang
  • 31
  • 8
  • Check `INSERT INTO SELECT` statement. https://dev.mysql.com/doc/refman/8.0/en/insert-select.html – Madhur Bhaiya Sep 09 '18 at 09:50
  • I know this statement,This statement does not meet my current requirements – songzeyang Sep 09 '18 at 09:55
  • 2
    if your already know the insert Select sql commando then explain better your question – ScaisEdge Sep 09 '18 at 09:57
  • 1
    Perhaps you need mysqldump heres a reference https://dba.stackexchange.com/questions/9306/how-do-you-mysqldump-specific-tables and there's always the manual. – P.Salmon Sep 09 '18 at 10:18
  • 1
    Possible duplicate of [How to dump only specific tables from MySQL?](https://stackoverflow.com/questions/2987366/how-to-dump-only-specific-tables-from-mysql) – madflow Sep 09 '18 at 11:02

1 Answers1

0

This is the answer I got by looking at other people

mysqldump -uroot -p learn tb_user >dump.sql

but imperfect,Because I want to achieve this through JDBC

songzeyang
  • 31
  • 8
  • Do you really "want to achieve this through JDBC", or do you simply want to achieve this from within your Java application? (There's a difference.) – Gord Thompson Sep 09 '18 at 13:12