• LightDB兼容Oracle table_exists_action功能


    LightDB是恒生电子推出的同时支持在线事务处理与在线分析处理的融合型分布式数据库产品,具备SQL兼容性高、容量弹性伸缩、金融级高可用、现代硬件融合、纯内存计算等核心特性,主要适用于对可用性、一致性要求较高的系统。

    为了持续提高对Oracle的兼容性,LightDB的下一版本将支持类似Oracle impdp中的table_exists_action功能。主要目的在于给予用户更多的选择权,即当将要导入的表在库中已存在时,如何处理。

    我们看一下LightDB导入工具lt_restore, --help如下:

    [postgres@pc]$ lt_restore --help
    lt_restore restores a LightDB database from an archive created by lt_dump.
    
    Usage:
      lt_restore [OPTION]... [FILE]
    
    General options:
      -d, --dbname=NAME        connect to database name
      -f, --file=FILENAME      output file name (- for stdout)
      -F, --format=c|d|t       backup file format (should be automatic)
      -l, --list               print summarized TOC of the archive
      -v, --verbose            verbose mode
      -V, --version            output version information, then exit
      -?, --help               show this help, then exit
    
    Options controlling the restore:
      -a, --data-only              restore only the data, no schema
      -c, --clean                  clean (drop) database objects before recreating
      -K, --recreate-schema        directly clean (drop) schemas before recreating, more faster then -c command
      -C, --create                 create the target database
      -e, --exit-on-error          exit on error, default is to continue
      -I, --index=NAME             restore named index
      -j, --jobs=NUM               use this many parallel jobs to restore
      -L, --use-list=FILENAME      use table of contents from this file for
                                   selecting/ordering output
      -n, --schema=NAME            restore only objects in this schema
      -N, --exclude-schema=NAME    do not restore objects in this schema
      -O, --no-owner               skip restoration of object ownership
      -P, --function=NAME(args)    restore named function
      -s, --schema-only            restore only the schema, no data
      -S, --superuser=NAME         superuser user name to use for disabling triggers
      -t, --table=NAME             restore named relation (table, view, etc.)
      -T, --trigger=NAME           restore named trigger
      -x, --no-privileges          skip restoration of access privileges (grant/revoke)
      -1, --single-transaction     restore as a single transaction
      --table_exists_action=skip|append|truncate|replace
                                   tells restore what to do if the table is already exists
      --disable-triggers           disable triggers during data-only restore
      --enable-row-security        enable row security
      --if-exists                  use IF EXISTS when dropping objects
      --no-comments                do not restore comments
      --no-data-for-failed-tables  do not restore data of tables that could not be
                                   created
      --no-publications            do not restore publications
      --no-security-labels         do not restore security labels
      --no-subscriptions           do not restore subscriptions
      --no-tablespaces             do not restore tablespace assignments
      --section=SECTION            restore named section (pre-data, data, or post-data)
      --strict-names               require table and/or schema include patterns to
                                   match at least one entity each
      --use-set-session-authorization
                                   use SET SESSION AUTHORIZATION commands instead of
                                   ALTER OWNER commands to set ownership
    
    Connection options:
      -h, --host=HOSTNAME      database server host or socket directory
      -p, --port=PORT          database server port number
      -U, --username=NAME      connect as specified database user
      -w, --no-password        never prompt for password
      -W, --password           force password prompt (should happen automatically)
      --role=ROLENAME          do SET ROLE before restore
    
    The options -I, -n, -N, -P, -t, -T, and --section can be combined and specified
    multiple times to select multiple objects.
    
    If no input file name is supplied, then standard input is used.
    
    Report bugs to .
    LightDB home page: 
    
    • 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
    • 65
    • 66
    • 67
    • 68
    • 69

    可以看到lt_restore已经支持 --table_exists_action=skip|append|truncate|replace。下面我们解释一下各个选项的含义:

    TABLE_EXISTS_ACTION具体含义如下:

    • skip:如果目标库中表已存在,则跳过,不再导入数据
    • append: 如果目标库中表已存在,则只追加数据,不修改表
    • truncate: 如果目标库中表已存在,则先将原有表中的数据删除,再导入数据,如果因为外键等原因无法truncate,则报错。
    • replace:如果目标库中表已存在,则先drop掉原有的表,在创建新表,导入数据。

    如何使用呢?看一个例子:

    lt_dump -Fc mydb > mydb.dump   --  导出库
    createdb -T template0 newdb    -- 建新库
    lt_restore -d newdb mydb.dump --table_exists_action = skip  -- 导入新库   
    
    • 1
    • 2
    • 3

    更详细的信息请参考LightDB官网:https://www.hs.net/lightdb。

  • 相关阅读:
    Recurrent vs. Recursive Neural Networks | 递归神经网络和循环神经网络的RNN之争
    (三)CSS前端开发面试会问到的问题有哪些?
    【Redis】第1讲 互联网架构的演变历程
    SQLite3数据类型
    vue前端学习——axiosAPI请求
    Python中的自然语言处理和文本挖掘
    贪心 Leetcode 135 分发糖果
    Delphi 开发so库,Delphi 调用SO库
    2 万字 + 30 张图 | 细聊 MySQL undo log、redo log、binlog 有什么用?
    Kotlin设计模式:享元模式(Flyweight Pattern)
  • 原文地址:https://blog.csdn.net/s_lisheng/article/details/127804672