如果您通过使用 GET DESCRIPTOR 语句的 DATA 子句从描述符区域取得 lvarchar pointer 或 var binary,则该值以空终止。如果对这样一个变量使用 ifx_var_getlen(),则返回的长度包括空终止符。要取得正确的长度,请使用 GET DESCRIPTOR 语句的 LENGTH 子句。
返回代码
>=0 var_bin 主变量的数据缓冲区的长度。 <0 函数不成功。
100 |20 gsql -d human_resource -p 15432 gsql ((GBase8c 3.0.0BXX build d28887c9) compiled at 2022-05-13 11:31:40 commit 0 last mr 55 ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. human_resource=# drop table hr.staffs CASCADE; NOTICE: drop cascades to view hr.staff_details_view DROP TABLE gs_restore /home/gbase/backup/MPPDB_backup.tar -p 15432 -d human_resource -n hr -t staffs -s -e Password: restore operation successful total time: 904 ms
GBase 8c V5 开发者手册 南大通用数据技术股份有限公司 322 示例九:执行gs_restore,导入staffs 和areas 两个指定表的定义和数据。在导入之前, staffs 和areas 表不存在。 human_resource=# \d List of relations Schema Name | Type | Owner | Storage --------+--------------------+-------+----------+---------------------------------- hr | employment_history | table | gbase | {orientation=row,compression=no} hr | employments | table | gbase | {orientation=row,compression=no} hr | places | table | gbase | {orientation=row,compression=no} hr | sections | table | gbase | {orientation=row,compression=no} hr | states | table | gbase | {orientation=row,compression=no} (5 rows) gs_restore /home/gbase/backup/MPPDB_backup.tar -p 15432 -d human_resource -n hr -t staffs -n hr -t areas Password: restore operation successful total time: 724 ms human_resource=# \d List of relations Schema | Name | Type | Owner | Storage --------+--------------------+-------+----------+---------------------------------- hr | areas | table | gbase | {orientation=row,compression=no} hr | employment_history | table | gbase | {orientation=row,compression=no} hr | employments | table | gbase | {orientation=row,compression=no} hr | places | table | gbase | {orientation=row,compression=no} hr | sections | table | gbase | {orientation=row,compression=no} hr | staffs | table | gbase | {orientation=row,compression=no} hr | states | table | gbase | {orientation=row,compression=no} (7 rows) human_resource=# select * from hr.areas; area_id | area_name ---------+------------------------ 4 | Middle East and Africa 1 | Europe | Americas | Asia (4 rows) 示例十:执行gs_restore,导入hr 的模式,包含模式下的所有对象定义和数据。 gs_restore /home/gbase/backup/MPPDB_backup1.dmp -p 15432 -d backupdb -n hr -e Password: restore operation successful total time: 702 ms
GBase 8c V5 开发者手册 南大通用数据技术股份有限公司 323 示例十一:执行gs_restore,同时导入hr 和hr1 两个模式,仅导入模式下的所有对象定 义。 gs_restore /home/gbase/backup/MPPDB_backup2.dmp -p 15432 -d backupdb -n hr -n hr1 -s Password: restore operation successful total time: 665 ms 示例十二: 执行gs_restore, 将human_resource 数据库导出文件导入至backupdb 数据库 中。 postgres=# create database backupdb; CREATE DATABASE gs_restore /home/gbase/backup/MPPDB_backup.tar -p 15432 -d backupdb restore operation successful total time: 23472 ms gsql -d backupdb -p 15432 -r gsql ((GBase8c 3.0.0BXX build d28887c9) compiled at 2022-05-13 11:31:40 commit 0 last mr 55 ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. gbase=# postgres=# select * from hr.areas; area_id |area_name ---------+------------------------ 4 | Middle East and Africa 1 | Europe | Americas | Asia (4 rows) 示例十三: 用户user1 不具备将导出文件中数据导入至数据库backupdb 的权限, 而角色 role1 具备该权限,要实现将文件数据导入数据库backupdb,可以在导出命令中设置--role 角色为role1,使用role1 的权限,完成导出目的。 human_resource=# CREATE USER user1 IDENTIFIED BY "1234@abc"; CREATE ROLE role1 with SYSADMIN IDENTIFIED BY "abc@1234"; gs_restore -U user1 /home/gbase/backup/MPPDB_backup.tar -p 15432 -d backupdb --role role1 -- rolepassword abc@1234 Password: restore operation successful total time: 554 ms gsql -d backupdb -p 15432 -r gsql ((GBase8c 3.0.0BXX build d28887c9) compiled at 2022-05-13 11:31:40 commit 0 last mr 55 )
GBase 8c V5 开发者手册 南大通用数据技术股份有限公司 324 Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. postgres=# select * from hr.areas; area_id | area_name ---------+------------------------ 4 | Middle East and Africa 1 | Europe | Americas | Asia (4 rows)