插入一行或修改指定行中的数据。
Namespace: Aliyun.OpenServices.OpenTableService
Assembly: Aliyun.OpenServices (in Aliyun.OpenServices.dll) Version: 1.0.5290.21916
Syntax
Parameters
- tableName
- Type: SystemString
表(Table)名,不能为视图(View)名。 - rowChange
- Type: Aliyun.OpenServices.OpenTableServiceRowPutChange
包含数据的RowPutChange对象。 - transactionId
- Type: SystemString
事务ID,不为空时表示该操作在该事务中进行。
Implements
IOtsPutData(String, RowPutChange, String)Exceptions
Exception | Condition |
---|---|
ArgumentException | tableName为空引用或值为空字符串, - 或 - talbeName违反OTS名称的命名规则。 - 或 - rowChange包含的信息无效。 |
ArgumentNullException | row为空引用。 |
OtsException | OTS访问返回错误消息。 |
WebException | 由于网络原因请求失败, - 或 - 访问超时。 |
InvalidOperationException | 返回结果解析错误。 |
Examples
using System; using System.Linq; using Aliyun.OpenTableService; namespace Aliyun.OpenServices.Samples.OpenTableService { class CreateTableSample { string endpoint = "http://ots.aliyuncs.com"; string accessId = "<your access id>"; string accessKey = "<your access key>"; string tableName = "contact_table"; string viewName = "view1"; public void CreateTable() { // 创建表结构信息。 var tableMeta = new TableMeta(tableName); // 指定表的主键。 tableMeta.PrimaryKeys.Add("uid", PrimaryKeyType.Integer); tableMeta.PrimaryKeys.Add("flag", PrimaryKeyType.Boolean); tableMeta.PrimaryKeys.Add("name", PrimaryKeyType.String); tableMeta.PagingKeyLength = 2; var viewMeta = new ViewMeta(viewName); viewMeta.PrimaryKeys.Add("uid", PrimaryKeyType.Integer); viewMeta.PrimaryKeys.Add("flag", PrimaryKeyType.Boolean); tableMeta.PrimaryKeys.Add("name", PrimaryKeyType.String); viewMeta.PrimaryKeys.Add("groupid", PrimaryKeyType.Integer); tableMeta.Views.Add(viewMeta); // 在OTS中创建一个表。 var otsClient = new OtsClient(endpoint, accessId, accessKey); try { otsClient.CreateTable(tableMeta); } catch (OtsException ex) { Console.WriteLine("创建表失败。OTS异常消息:" + ex.Message); // RequestId和HostId可以在有问题时用于联系客服诊断异常。 Console.WriteLine("Request ID: {0}\tHostID: {1}", ex.RequestId, ex.HostId); } catch (System.Net.WebException ex) { Console.WriteLine("创建表失败。网络异常:{0}。请检查Endpoint或网络链接。", ex.Message); } } } }
See Also