返回首页

gbase数据、南大通用产品文档:GBase8c

更新日期:2024年09月11日

导出全局对象
GBase 8c 支持使用gs_dumpall 工具导出所有数据库公共的全局对象,包含数据库用户
和组,表空间及属性(例如:适用于数据库整体的访问权限)信息。
操作步骤
步骤1 以操作系统用户gbase 登录数据库主节点。
步骤2 使用gs_dumpall 导出表空间对象信息。
gs_dumpall -U gbase -f /home/gbase/backup/MPPDB_tablespace.sql -p 15432 -t
Password:
表10-6 常用参数说明

GBase 8c V5 开发者手册
南大通用数据技术股份有限公司
350
参数
参数说明
举例
-U
连接数据库的用户名。
说明:
不指定连接数据库的用户名时,
默认以安装时创
建的初始系统管理员连接。
-U jack
-W
指定用户连接的密码。

如果主机的认证策略是trust,则不会对数据库管
理员进行密码验证,即无需输入-W 选项;

如果没有-W 选项,并且不是数据库管理员,会提
示用户输入密码。
-W abcd@123
-f
将导出文件发送至指定目录文件夹。
如果这里省略,

使用标准输出。
-f
home/gbase/backup/
postgres_backup.tar
-p
指定服务器所侦听的TCP 端口或本地Unix 域套接字后
缀,以确保连接。
-p 15432
-t
指定导出的表(或视图、序列、外表),可以使用多个
-t 选项来选择多个表,
也可以使用通配符指定多个表对
象。当使用通配符指定多个表对象时,注意给pattern
打引号,防止shell 扩展通配符。

单个表:-t schema.table

多个表:多次输入-t schema.table

单个表:-t
hr.staffs

多个表:-t
hr.staffs
-
t
hr.employment
s
其他参数说明请参见《GBase 8c V5_3.0.x_工具参考》中“服务端工具> gs_dumpall”章
节。
----结束
示例
示例一:执行gs_dumpall,导出所有数据库的公共全局表空间信息和用户信息(gbase 用户
为管理员用户),导出文件为文本格式。
gs_dumpall -U gbase -f /home/gbase/backup/MPPDB_globals.sql -p 15432 -g
Password:
gs_dumpall[port='15432'][2018-11-14 19:06:24]: dumpall operation successful
gs_dumpall[port='15432'][2018-11-14 19:06:24]: total time: 1150 ms
示例二:执行gs_dumpall,导出所有数据库的公共全局表空间信息(gbase 用户为管理员用

GBase 8c V5 开发者手册
南大通用数据技术股份有限公司
351
户),并对导出文件进行加密,导出文件为文本格式。
gs_dumpall -U gbase -f /home/gbase/backup/MPPDB_tablespace.sql -p 15432 -t
--with-encryption AES128
--with-key abcdefg_?1234567
Password:
gs_dumpall[port='15432'][2018-11-14 19:00:58]: dumpall operation successful
gs_dumpall[port='15432'][2018-11-14 19:00:58]: total time: 186 ms
示例三:
执行gs_dumpall,
导出所有数据库的公共全局用户信息
(gbase 用户为管理员用户)

导出文件为文本格式。
gs_dumpall -U gbase -f /home/gbase/backup/MPPDB_user.sql -p 15432 -r
Password:
gs_dumpall[port='15432'][2018-11-14 19:03:18]: dumpall operation successful
gs_dumpall[port='15432'][2018-11-14 19:03:18]: total time: 162 ms


查看 GBase 8s ODBC Driver 可以返回的 SQLSTATE 值。
下表映射 GBase 8s ODBC Driver 可以返回的 SQLSTATE 值。
SQL_SUCCESS 的返回值通常表示函数执行成功,尽管 SQLSTATE 00000 也表示成功。
SQLSTATE
错误消息
从这里返回
01 000
General warning
所有的 GBase 8s ODBC Driver 函数,除了:
SQLAllocEnv SQLError
01002
Disconnect error
SQLDisconnect
01004
Data truncated
SQLBrowseConnect SQLColAttributes
SQLDataSources SQLDescribeCol
SQLDriverConnect SQLDrivers
SQLExecDirect SQLExecute
SQLExtendedFetch SQLFetch
SQLGetCursorName SQLGetData
SQLGetInfo SQLNativeSql
SQLPutData SQLSetPos
01006
Privilege not revoked
SQLExecDirect SQLExecute
01S00
Invalid connection
string attribute
SQLBrowseConnect SQLDriverConnect
01S01
Error in row
SQLExtendedFetch SQLSetPos
01S02
Option value changed
SQLSetConnectOption SQLSetStmtOption

GBase 8s ODBC Driver 程序员指南
南大通用数据技术股份有限公司
- 202 -
SQLSTATE
错误消息
从这里返回
01S03
No rows updated or
deleted
SQLExecDirect SQLExecute
SQLSetPos
01S04
More than one row
updated or deleted
SQLExecDirect SQLExecute
SQLSetPos
07001
Wrong number of
parameters
SQLExecDirect SQLExecute
07006
Restricted data type
attribute violation
SQLBindParameter SQLExtendedFetch
SQLFetchSQLGetData
08001
Unable to connect to
data source
SQLBrowseConnect SQLConnect
SQLDriverConnect
08002
Connection in use
SQLBrowseConnect SQLConnect
SQLDriverConnect SQLSetConnectOption
08003
Connection not open
SQLAllocStmt SQLDisconnect
SQLGetConnectOption SQLGetInfo
SQLNativeSql SQLSetConnectOption
SQLTransact
08004
Data source rejected
establishment of
connection
SQLBrowseConnect SQLConnect
SQLDriverConnect
08007
Connection failure
during transaction
SQLTransact
08S01
Communication link
failure
SQLBrowseConnect SQLColumnPrivileges
SQLColumns SQLConnect
SQLDriverConnect SQLExecDirect
SQLExecute SQLExtendedFetch
SQLFetch SQLForeignKeys
SQLFreeConnect SQLGetData
SQLGetTypeInfo SQLParamData
SQLPrepare SQLPrimaryKeys
SQLProcedureColumns SQLProcedures
SQLPutDataSQL SetConnectOption
SQLSetStmtOption SQLSpecialColumns
SQLStatistics SQLTablePrivileges
SQLTables
21S01
Insert value list does
not match column list
SQLExecDirect SQLPrepare
21S02
Degree of derived
table does not match
column list
SQLExecDirect SQLPrepare SQLSetPos
22001
String data right
truncation
SQLPutData

GBase 8s ODBC Driver 程序员指南
南大通用数据技术股份有限公司
- 203 -
SQLSTATE
错误消息
从这里返回
22003
Numeric value out of
range
SQLExecDirect SQLExecute
SQLExtendedFetch SQLFetch
SQLGetData SQLGetInfo
SQLPutData SQLSetPos
22005
Error in assignment
SQLExecDirect SQLExecute
SQLExtendedFetch SQLFetch
SQLGetData SQLPrepare
SQLPutData SQLSetPos
22008
Datetime field
overflow
SQLExecDirect SQLExecute
SQLExtendedFetch
SQLFetchSQLGetData
SQLPutDataSQLSetPos
22012
Division by zero
SQLExecDirect SQLExecute
SQLExtendedFetch SQLFetchSQLGetData
22026
String data, length
mismatch
SQLParamData
23000
Integrity constraint
violation
SQLExecDirect SQLExecute
SQLSetPos
24000
Invalid cursor state
SQLColAttributes SQLColumnPrivileges
SQLColumns SQLDescribeCol
SQLExecDirect SQLExecute
SQLExtendedFetch SQLFetch
SQLForeignKeys SQLGetData
SQLGetStmtOption SQLGetTypeInfo
SQLPrepare SQLPrimaryKeys
SQLProcedureColumns SQLProcedures
SQLSetCursorName SQLSetPos
SQLSetStmtOption SQLSpecialColumns
SQLStatistics SQLTablePrivileges
SQLTables
25000
Invalid transaction
state
SQLDisconnect
28000
Invalid authorization
specification
SQLBrowseConnect SQLConnectS
QLDriverConnect
34000
Invalid cursor name
SQLExecDirect SQLPrepare
SQLSetCursorName
37000
Syntax error or access
violation
SQLExecDirect SQLNativeSql
SQLPrepare
3C000
Duplicate cursor name
SQLSetCursorName
40001
Serialization failure
SQLExecDirect SQLExecute
SQLExtendedFetch SQLFetch

GBase 8s ODBC Driver 程序员指南
南大通用数据技术股份有限公司
- 204 -
SQLSTATE
错误消息
从这里返回
42000
Syntax error or access
violation
SQLExecDirect SQLExecute
SQLPrepare SQLSetPos
70100
Operation aborted
SQLCancel
IM001
Driver does not
support this function
所有的 ODBC 函数,除了:
SQLAllocConnect SQLAllocEnv
SQLDataSources SQLDrivers
SQLError SQLFreeConnect
SQLFreeEnv SQLGetFunctions
IM002
Data source name not
found and no default
driver specified
SQLBrowseConnect
SQLConnect
SQLDriverConnect
IM003
Specified driver could
not be loaded
SQLBrowseConnect SQLConnect
SQLDriverConnect
IM004
Driver's
SQLAllocEnv failed
SQLBrowseConnect SQLConnect
SQLDriverConnect
IM005
Driver's
SQLAllocConnect
failed
SQLBrowseConnect SQLConnect
SQLDriverConnect
IM006
Driver's
SQLSetConnectOptio
n failed
SQLBrowseConnect SQLConnect
SQLDriverConnect
IM007
No data source or
driver specified;
dialog prohibited
SQLDriverConnect
IM008
Dialog failed
SQLDriverConnect
IM009
Unable to load
translation shared
library (DLL)
SQLBrowseConnect SQLConnect
SQLDriverConnect SQLSetConnectOption
IM010
Data source name too
long
SQLBrowseConnect SQLDriverConnect
IM011
Driver name too long
SQLBrowseConnect SQLDriverConnect
IM012
DRIVER keyword
syntax error
SQLBrowseConnect SQLDriverConnect
IM013
Trace file error
All ODBC functions.
S0001
Base table or view
already exists
SQLExecDirectSQLPrepare
S0002
Base table not found
SQLExecDirectSQLPrepare
S0011
Index already exists
SQLExecDirectSQLPrepare
S0012
Index not found
SQLExecDirectSQLPrepare
S0021
Column already exists
SQLExecDirectSQLPrepare
S0022
Column not found
SQLExecDirectSQLPrepare

GBase 8s ODBC Driver 程序员指南
南大通用数据技术股份有限公司
- 205 -
SQLSTATE
错误消息
从这里返回
S0023
No default for column
SQLSetPos
S1000
General error
所有的 ODBC 函数
S1001
Memory allocation
failure
所有的 ODBC 函数,除了:
SQLAllocEnv SQLError
SQLFreeConnect SQLFreeEnv
S1002
Invalid column
number
SQLBindCol SQLColAttributes
SQLDescribeCol SQLExtendedFetchS
QLFetch SQLGetData
S1003
Program type out of
range
SQLBindCol SQLBindParameter
SQLGetData
S1004
SQL data type out of
range
SQLBindParameter SQLGetTypeInfo
S1008
Operation canceled
所有可以执行异步的 ODBC 函数:
SQLColAttributes SQLColumnPrivileges
SQLColumns SQLDescribeCol
SQLDescribeParam SQLExecDirect
SQLExecute SQLExtendedFetch
SQLFetch SQLForeignKeys
SQLGetData SQLGetTypeInfo
SQLMoreResults SQLNumParams
SQLNumResultCols SQLParamData
SQLPrepare SQLPrimaryKeys
SQLProcedureColumns SQLProcedures
SQLPutData SQLSetPos
SQLSpecialColumns SQLStatistics
SQLTablePrivileges SQLTables
S1009
Invalid argument
value
SQLAllocConnect SQLAllocStmt
SQLBindCol SQLBindParameter
SQLExecDirect SQLForeignKeys
SQLGetData SQLGetInfo
SQLNativeSql SQLPrepare
SQLPutData SQLSetConnectOption
SQLSetCursorName SQLSetPos
SQLSetStmtOption
S1010
Function sequence
error
SQLBindCol SQLBindParameter
SQLColAttributes SQLColumnPrivileges
SQLColumns SQLDescribeCol
SQLDisconnect SQLExecDirect
SQLExecute SQLExtendedFetch
SQLFetch SQLForeignKeys
SQLFreeConnect SQLFreeEnv

GBase 8s ODBC Driver 程序员指南
南大通用数据技术股份有限公司
- 206 -
SQLSTATE
错误消息
从这里返回
SQLFreeStmt SQLGetConnectOption
SQLGetCursorName SQLGetData
SQLGetFunctions SQLGetStmtOption
SQLGetTypeInfo SQLMoreResults
SQLNumParams SQLNumResultColsS
QLParamData SQLParamOptions
SQLPrepare SQLPrimaryKeys
SQLProcedureColumns SQLProcedures
SQLPutData SQLRowCount
SQLSetConnectOption SQLSetCursorName
SQLSetPos SQLSetScrollOptions
SQLSetStmtOption SQLSpecialColumns
SQLStatistics SQLTablePrivileges
SQLTables SQLTransact
S1011
Operation invalid at
this time
SQLGetStmtOption SQLSetConnectOption
SQLSetStmtOption
S1012
Invalid transaction
operation code
specified
SQLTransact
S1015
No cursor name
available
SQLGetCursorName
S1090
Invalid string or
buffer length
SQLBindCol SQLBindParameter
SQLBrowseConnect SQLColAttributes
SQLColumnPrivileges SQLColumns
SQLConnect SQLDataSources
SQLDescribeCol SQLDriverConnect
SQLDrivers SQLExecDirect
SQLExecute SQLForeignKeys
SQLGetCursorName SQLGetData
SQLGetInfo SQLNativeSql
SQLPrepare SQLPrimaryKeys
SQLProcedureColumns SQLProcedures
SQLPutData SQLSetCursorName
SQLSetPos SQLSpecialColumns
SQLStatistics SQLTablePrivileges
SQLTables
S1091
Descriptor type out of
range
SQLColAttributes
S1092
Option type out of
range
SQLFreeStmt SQLGetConnectOption
SQLGetStmtOption SQLSetConnectOption
SQLSetStmtOption

GBase 8s ODBC Driver 程序员指南
南大通用数据技术股份有限公司
- 207 -
SQLSTATE
错误消息
从这里返回
S1093
Invalid parameter
number
SQLBindParameter
S1094
Invalid scale value
SQLBindParameter
S1095
Function type out of
range
SQLGetFunctions
S1096
Information type out
of range
SQLGetInfo
S1097
Column type out of
range
SQLSpecialColumns
S1098
Scope type out of
range
SQLSpecialColumns
S1099
Nullable type out of
range
SQLSpecialColumns
S1100
Uniqueness option
type out of range
SQLStatistics
S1101
Accuracy option type
out of range
SQLStatistics
S1103
Direction option out
of range
SQLDataSources
SQLDrivers
S1104
Invalid precision
value
SQLBindParameter
S1105
Invalid parameter type
SQLBindParameter
S1106
Fetch type out of
range
SQLExtendedFetch
S1107
Row value out of
range
SQLExtendedFetch
SQLParamOptions SQLSetPos
SQLSetScrollOptions
S1108
Concurrency option
out of range
SQLSetScrollOptions
S1109
Invalid cursor position
SQLExecute SQLExecDirect
SQLGetData SQLGetStmtOption
SQLSetPos
S1110
Invalid driver
completion
SQLDriverConnect
S1111
Invalid bookmark
value
SQLExtendedFetch
S1C00
Driver not capable
SQLBindCol SQLBindParameter
SQLColAttributes SQLColumnPrivileges
SQLColumns SQLExecDirect
SQLExecute SQLExtendedFetch
SQLFetch SQLForeignKeys

GBase 8s ODBC Driver 程序员指南
南大通用数据技术股份有限公司
- 208 -
SQLSTATE
错误消息
从这里返回
SQLGetData SQLTablePrivileges
SQLGetInfo SQLGetStmtOption
SQLGetTypeInfo SQLPrepare
SQLPrimaryKeys SQLTransact
SQLProcedures SQLSetConnectOption
SQLSetPosSQL SQLTables
SQLSetStmtOption SQLSpecialColumns
SQLStatistics SQLTransact
SetScrollOptions
SQLProcedureColumns
SQLGetConnectOption
S1T00
Time-out expired
SQLBrowseConnect SQLColAttributes
SQLColumnPrivileges SQLColumns
SQLConnect SQLDescribeCol
SQLDriverConnect SQLExecDirect
SQLExecute SQLExtendedFetch
SQLFetch SQLForeignKeys
SQLGetData SQLGetInfo
SQLGetTypeInfo SQLMoreResults
SQLNumParams SQLNumResultCols
SQLParamData SQLPrepare
SQLPrimaryKeys SQLProcedureColumns
SQLProcedures SQLPutData
SQLSetPos SQLSpecialColumns
SQLStatistics SQLTablePrivileges
SQLTables

删除 tenant 数据库
(SQL
管理 API)
随同 admin() 或 task() 函数,使用 tenant drop 参数来删除 tenant 数据库。
语法

元素
描述
关键考虑
database_name
tenant 数据库的名称。 必须是现有的 tenant 数据
库。

用法
您必须拥有 DBA 权限或已被授予 TENANT 权限来运行这个命令。不可打开其他到该数
据库的连接。
删除该数据库中的表和数据。释放 tenant 数据库专用的存储空间。从 sysadmin 数据库中
的 tenant 表中移除数据库 tenant 属性。如果不与其他任何 tenant 数据库相关,则删除相
关的 tenant 虚拟处理器类。
下列语句删除 companyA tenant 数据库:
EXECUTE FUNCTION task('tenant drop', 'companyA');