返回首页

gbase数据、南大通用产品文档:GBase8armfeventlog 命令

更新日期:2024年09月11日

功能
执行节点替换操作前,使用该命令将被替换节点(已被设置为unavailable 状态)的
所有fevent log(DDL fevent log、DML fevent log、DMLStorage fevent log)删除。
警告

慎重使用,非节点替换操作请勿使用;

执行后会提示让管理员再次确认。
语法
gcadmin rmfeventlog ip

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
196

功能说明

GBase 8a MPP Cluster 产品手册
5 数据库管理指南
文档版本953(2022-04-10)
南大通用数据技术股份有限公司
1003
关闭预租磁盘空间。
语法格式
ALTER TABLE [vc_name.][database_name.]table_name AUTOEXTEND OFF;
表5- 75 参数说明
参数名称


vc_name
vc 名,可选项。
database_name
数据库名,可选项。
table_name
表名。
示例
示例1:关闭表的指定预租磁盘空间大小。
gbase> CREATE TABLE t(nameid int, name varchar(50)) AUTOEXTEND ON NEXT 1M;
Query OK, 0 rows affected
gbase> SHOW CREATE TABLE t\G
*************************** 1. row ***************************
Table: t
Create Table: CREATE TABLE "t" (
"nameid" int(11) DEFAULT NULL,
"name" varchar(50) DEFAULT NULL
)
ENGINE=EXPRESS
DEFAULT
CHARSET=utf8
TABLESPACE='sys_tablespace'
AUTOEXTEND ON NEXT 1M
1 row in set (Elapsed: 00:00:00.00)
gbase> ALTER TABLE t AUTOEXTEND OFF;
Query OK, 0 rows affected
Records: 0
Duplicates: 0
Warnings: 0
gbase> SHOW CREATE TABLE t\G
*************************** 1. row ***************************
Table: t
Create Table: CREATE TABLE "t" (
"nameid" int(11) DEFAULT NULL,
"name" varchar(50) DEFAULT NULL
) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace'
1 row in set (Elapsed: 00:00:00.00)

GBase 8a MPP Cluster 产品手册
5 数据库管理指南
文档版本953(2022-04-10)
南大通用数据技术股份有限公司
1004

支持GBase UP 的Blob Uri 字段的存取,使用时注意以下几点要求:

必须使用Prepare

必须使用Parameters

大文件必须使用FileStream 作为Parameters 的参数

Select 时必须将Blob Uri 字段放在所有字段最后

Select 时DataReader 必须使用CommandBehavior.SequentialAccess
流式读取模式

Select 时先执行GetBlobLength()获取Blob
Uri 字段值的长度,
再循
环执行GetBlob 获取
使用代码示例如下:
string connstr =
"server=192.168.8.29;database=song;uid=gbase;pwd=gbase20110531;pooling=false;
Ignore Prepare=false;";//连接参数中必须指定Ignore Prepare=false

FileStream fsin;
string filepath = @"d:\1.bmp";
string tablename = "test1";
fsin = new FileStream(filepath,FileMode.Open,FileAccess.Read);
long fsinlength = fsin.Length;
string sql = "drop table if exists " + tablename;
using (GBaseConnection conn = new GBaseConnection(connstr))
{
conn.Open();



GBase 8a 程序员手册ADO.NET 篇
南大通用数据技术股份有限公司

- 337 -
using (GBaseCommand cmd = new GBaseCommand(sql,conn))
{
cmd.ExecuteNonQuery();
cmd.CommandText = "create table " + tablename + " (a int, b blob uri, c
varchar(30))";
cmd.ExecuteNonQuery();

cmd.CommandText = "insert into " + tablename + " values(@a,@b,@c)";
cmd.CommandTimeout = 20000;
cmd.Parameters.AddWithValue("@a", 1);
cmd.Parameters.AddWithValue("@b", fsin); //将FileStream作为参数传入
cmd.Parameters.AddWithValue("@c", "song");
cmd.Prepare();//必须先Prepare
cmd.ExecuteNonQuery();
}
fsin.Close();

FileStream fsout;
string outpath = @"d:\outfile.bmp";
if (File.Exists(outpath))
{
File.Delete(outpath);
}
fsout = new FileStream(outpath, FileMode.OpenOrCreate, FileAccess.Write);

sql = "select a,c,b from " + tablename; //select时将blob uri字段放在最后
using (GBaseCommand cmd = new GBaseCommand(sql,conn))
{
cmd.Prepare();//开启prepare
cmd.CommandTimeout = 20000;//timeout设置大,防止在读取较大数据
时超时退出


GBase 8a 程序员手册ADO.NET 篇


- 338 -

南大通用数据技术股份有限公司
using (GBaseDataReader reader =
cmd.ExecuteReader(CommandBehavior.SequentialAccess)) //必须设置为流式读取
{
while (reader.Read())
{
Assert.AreEqual(1, reader.GetValue(0));
Assert.AreEqual("song", reader.GetValue(1));
long len = 0;
len = reader.GetBlobLength(2);//读取blob uri时,先获取列值的
长度 GetBlobLength
if (len == 0)
{
Console.WriteLine("blob uri is null");
}
Assert.AreEqual(len, fsinlength);//判断获取的长度等于存入时
的长度

byte[] result = null;
long alreadyRead = 0;//已经读取的长度
while (alreadyRead < len)//循环获取值
{
result = reader.GetBlob(2, alreadyRead); //读满,一个数据
包最大16M,内存够用 GetBlob
fsout.Write(result, 0, result.Length);
alreadyRead += result.Length;
}

fsout.Close();
}
}
}
}