navicat怎么批量处理数据


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

import java.io.File;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.IOException;

import java.sql.Date;

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class UserTest {

    public static void main(String[] args) {

        try {

            writeToFile();

            //readFromFile();

        } catch (IOException e) {

            e.printStackTrace();

        }

    }

    /**

     * DOC 往文件里写入数据.

     *

     * @throws IOException

     */

    private static void writeToFile() throws IOException {

        String writerContent = "";// 要写入的文本

        File file = new File("F:\\user.txt");// 要写入的文本文件

        if (!file.exists()) {// 如果文件不存在,则创建该文件

            file.createNewFile();

        }

        FileWriter writer = new FileWriter(file);// 获取该文件的输出流

        for (int i = 0 ;i < 10; i ++ ) {

            writerContent = "insert into `user` VALUES ("+"'"+(i + 1)+"'," +"yystrong"+i+"',"+"'111',"

                    +"'"+calcTime("", -(i+1))+"'"+"'0',"+"'0',"+"'"+calcTime("", -(i+1))+"'"

                    + "\r\n";

            writer.write(writerContent);// 写内容

        }

        writer.flush();// 清空缓冲区,立即将输出流里的内容写到文件里

        writer.close();// 关闭输出流,施放资源

    }

    /**

     *

     * @param type 往前计算的类型(week、month、year,“”表示day

     * @param count 往前计算的数量

     * @return

     */

    private static String calcTime(String type ,int count){

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        Calendar calendar = Calendar.getInstance();

        if (type .equals("week")) {

            //周

            calendar.add(Calendar.WEEK_OF_YEAR, count);

        }else if (type .equals("month")) {

            //月

            calendar.add(Calendar.MONTH, count);

        }else if (type .equals("year")) {

            //12个月

            calendar.add(Calendar.MONTH, count);

        }else {

            //日

            calendar.add(Calendar.DATE, count);

        }

        java.util.Date date = calendar.getTime();

        return sdf.format(date);

    }

}

执行之后,在f盘的根目录下就会创建一个user.txt的文件夹,里面有insert语句,然后在navicat里面选择ctrl+q打开执行框,复制进去之后选择运行,同样可以导入数据。

1566026713994394.png

以上就是navicat怎么批量处理数据的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

Navicat premium中如何清空表

Navicat怎么快捷运行选中行

Navicat错误代码1142怎么办

Navicat怎么授权远程访问

Navicat导入excel报错怎么办

Navicat连接1130错误如何解决

mysql安装后报错error 1045怎么办?

Navicat如何设置ssh属性

使用Navicat怎么导出整个数据库

Navicat for mysql 安装教程

更多相关阅读请进入《Navicat》频道 >>


数据库系统概念 第6版
书籍

数据库系统概念 第6版

机械工业出版社

本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...