今天遇到一个比较坑的问题,我用别人的数据库bmp备份文件在我本地的数据库做还原,总是备份失败,表结构有了,但是表里没有数据。联系了很多资源,最后找到问题了,是备份端备份方式采用的是导出sql的形式,但写的是dmp模式,需要新加schema模式。人大金仓数据库备份还原失败可能原因有两种:
1.两端的数据库版本不匹配:命令行 KingBase -V(人大金仓数据库对大小写敏感)
比如我本地的数据库版本是V008R003C002B0340而备份方的数据库版本小号最后不是340
2.采用导出dmp文件的形式备份,在还原数据库时没有新建schema模式,导致ksql命令行还原时,创建完表结构在,导入数据时一直找不到schema模式,所以报出来一堆???????
解决方法:
C:\windows\system32>ksql -UCQBC1 -d TEST -WCQBC1
ksql (V008R003C002B0340)
Type "help" for help.
TEST=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
CQBC1 | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
SYSSAO | | {}
SYSSSO | | {}
TEST=# create user CQBC password 'CQBC';
CREATE ROLE
TEST=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------+----------+---------+-------+-------------------
SAMPLES | CQBC1 | UTF8 | C | C |
SECURITY | CQBC1 | UTF8 | C | C |
TEMPLATE0 | CQBC1 | UTF8 | C | C | =c/CQBC1 +
| | | | | CQBC1=CTcb/CQBC1
TEMPLATE1 | CQBC1 | UTF8 | C | C | =c/CQBC1 +
| | | | | CQBC1=CTcb/CQBC1
TEMPLATE2 | CQBC1 | UTF8 | C | C | =Tc/CQBC1 +
| | | | | CQBC1=CTcb/CQBC1
TEST | CQBC1 | UTF8 | C | C |
(6 rows)
TEST=# create database CQBC1 owner CQBC;
CREATE DATABASE
TEST=# \c CQBC1
You are now connected to database "CQBC1" as user "CQBC1".
CQBC1=# \c - CQBC
Password for user CQBC:
致命错误: 用户 "CQBC" Password 认证失败
Previous connection kept
CQBC1=# \c - CQBC
Password for user CQBC:
You are now connected to database "CQBC1" as user "CQBC".
CQBC1=> create schema CQBC;
CREATE SCHEMA
CQBC1=> \q
C:\windows\system32>ksql -UCQBC -WCQBC -d CQBC1 -f F:\KingBase\BF\BJ\CQBC120220309.dmp