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:
可以看到lt_restore已经支持 --table_exists_action=skip|append|truncate|replace
。下面我们解释一下各个选项的含义:
TABLE_EXISTS_ACTION具体含义如下:
如何使用呢?看一个例子:
lt_dump -Fc mydb > mydb.dump -- 导出库
createdb -T template0 newdb -- 建新库
lt_restore -d newdb mydb.dump --table_exists_action = skip -- 导入新库
更详细的信息请参考LightDB官网:https://www.hs.net/lightdb。