doc-exports/docs/dli/api-ref/dli_02_0108.html
Su, Xiaomeng 57a0d535be dli_api_0910_version_api
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
2023-10-16 22:01:57 +00:00

198 lines
15 KiB
HTML

<a name="dli_02_0108"></a><a name="dli_02_0108"></a>
<h1 class="topictitle1">Previewing Table Content</h1>
<div id="body1524639341223"><div class="section" id="dli_02_0108__s4d7af3a55ba34cc0ad39319579f69b71"><h4 class="sectiontitle">Function</h4><p id="dli_02_0108__p64297182145722">This API is used to preview the first 10 rows in a table.</p>
</div>
<div class="section" id="dli_02_0108__s4d10c112744f4d8298e08964081970c4"><h4 class="sectiontitle">URI</h4><ul id="dli_02_0108__en-us_topic_0069077903_ul49091925"><li id="dli_02_0108__en-us_topic_0069077903_li39174147">URI format<p id="dli_02_0108__en-us_topic_0069077903_p17023004"><a name="dli_02_0108__en-us_topic_0069077903_li39174147"></a><a name="en-us_topic_0069077903_li39174147"></a>GET /v1.0/{project_id}/databases/{database_name}/tables/{table_name}/preview</p>
</li><li id="dli_02_0108__li28611846132312">Parameter description
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_02_0108__en-us_topic_0069077903_table18989315" frame="border" border="1" rules="all"><caption><b>Table 1 </b>URI parameters</caption><thead align="left"><tr id="dli_02_0108__en-us_topic_0069077903_row37144870"><th align="left" class="cellrowborder" valign="top" width="18.031803180318033%" id="mcps1.3.2.2.2.1.2.5.1.1"><p id="dli_02_0108__en-us_topic_0069077903_p621772417152">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="11.641164116411641%" id="mcps1.3.2.2.2.1.2.5.1.2"><p id="dli_02_0108__en-us_topic_0069077903_p721818240153">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="13.211321132113211%" id="mcps1.3.2.2.2.1.2.5.1.3"><p id="dli_02_0108__p1326615161531">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="57.11571157115712%" id="mcps1.3.2.2.2.1.2.5.1.4"><p id="dli_02_0108__a86c116e114d44f4c8e5ce60e82d3b11f">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_02_0108__row18156104824111"><td class="cellrowborder" valign="top" width="18.031803180318033%" headers="mcps1.3.2.2.2.1.2.5.1.1 "><p id="dli_02_0108__en-us_topic_0069077803_p43412436">project_id</p>
</td>
<td class="cellrowborder" valign="top" width="11.641164116411641%" headers="mcps1.3.2.2.2.1.2.5.1.2 "><p id="dli_02_0108__en-us_topic_0069077803_p26746391">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="13.211321132113211%" headers="mcps1.3.2.2.2.1.2.5.1.3 "><p id="dli_02_0108__p1226631617538">String</p>
</td>
<td class="cellrowborder" valign="top" width="57.11571157115712%" headers="mcps1.3.2.2.2.1.2.5.1.4 "><p id="dli_02_0108__p1310472724012">Project ID, which is used for resource isolation. For details about how to obtain its value, see <a href="dli_02_0183.html">Obtaining a Project ID</a>.</p>
</td>
</tr>
<tr id="dli_02_0108__en-us_topic_0069077903_row42334793"><td class="cellrowborder" valign="top" width="18.031803180318033%" headers="mcps1.3.2.2.2.1.2.5.1.1 "><p id="dli_02_0108__en-us_topic_0069077903_p6566175">database_name</p>
</td>
<td class="cellrowborder" valign="top" width="11.641164116411641%" headers="mcps1.3.2.2.2.1.2.5.1.2 "><p id="dli_02_0108__en-us_topic_0069077903_p62098166">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="13.211321132113211%" headers="mcps1.3.2.2.2.1.2.5.1.3 "><p id="dli_02_0108__p19267716155314">String</p>
</td>
<td class="cellrowborder" valign="top" width="57.11571157115712%" headers="mcps1.3.2.2.2.1.2.5.1.4 "><p id="dli_02_0108__p29276378145758">Name of the database where the table to be previewed resides.</p>
</td>
</tr>
<tr id="dli_02_0108__en-us_topic_0069077903_row38188964"><td class="cellrowborder" valign="top" width="18.031803180318033%" headers="mcps1.3.2.2.2.1.2.5.1.1 "><p id="dli_02_0108__en-us_topic_0069077903_p6298355">table_name</p>
</td>
<td class="cellrowborder" valign="top" width="11.641164116411641%" headers="mcps1.3.2.2.2.1.2.5.1.2 "><p id="dli_02_0108__en-us_topic_0069077903_p40404735">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="13.211321132113211%" headers="mcps1.3.2.2.2.1.2.5.1.3 "><p id="dli_02_0108__p192675165532">String</p>
</td>
<td class="cellrowborder" valign="top" width="57.11571157115712%" headers="mcps1.3.2.2.2.1.2.5.1.4 "><p id="dli_02_0108__p43359460145811">Name of the table to be previewed.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_02_0108__table430114206570" frame="border" border="1" rules="all"><caption><b>Table 2 </b>query parameter description</caption><thead align="left"><tr id="dli_02_0108__row163026209572"><th align="left" class="cellrowborder" valign="top" width="10.061006100610062%" id="mcps1.3.2.2.2.2.2.5.1.1"><p id="dli_02_0108__p143022207572">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="10.791079107910791%" id="mcps1.3.2.2.2.2.2.5.1.2"><p id="dli_02_0108__p14302172035714">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="10.071007100710071%" id="mcps1.3.2.2.2.2.2.5.1.3"><p id="dli_02_0108__p830292095716">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="69.07690769076908%" id="mcps1.3.2.2.2.2.2.5.1.4"><p id="dli_02_0108__p13028209577">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_02_0108__row0307142005711"><td class="cellrowborder" valign="top" width="10.061006100610062%" headers="mcps1.3.2.2.2.2.2.5.1.1 "><p id="dli_02_0108__p163071020205716">mode</p>
</td>
<td class="cellrowborder" valign="top" width="10.791079107910791%" headers="mcps1.3.2.2.2.2.2.5.1.2 "><p id="dli_02_0108__p130719203576">No</p>
</td>
<td class="cellrowborder" valign="top" width="10.071007100710071%" headers="mcps1.3.2.2.2.2.2.5.1.3 "><p id="dli_02_0108__p14307132065713">String</p>
</td>
<td class="cellrowborder" valign="top" width="69.07690769076908%" headers="mcps1.3.2.2.2.2.2.5.1.4 "><p id="dli_02_0108__p0307122055710">Preview table mode. The options are <span class="parmvalue" id="dli_02_0108__parmvalue8647202052515"><b>SYNC</b></span> and <span class="parmvalue" id="dli_02_0108__parmvalue196521620162520"><b>ASYNC</b></span>. The default value is <span class="parmvalue" id="dli_02_0108__parmvalue106521020102520"><b>SYNC</b></span>.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="dli_02_0108__note317183871"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dli_02_0108__p142613474">The following is an example of the URL containing the <strong id="dli_02_0108__b5361102213257">query</strong> parameter:</p>
<p id="dli_02_0108__p579542212147">GET /v1.0/{project_id}/databases/{database_name}/tables/{table_name}/preview?mode=<em id="dli_02_0108__i17114382144">{<i><span class="varname" id="dli_02_0108__varname871173820145">previewMode}</span></i></em></p>
</div></div>
</li></ul>
</div>
<div class="section" id="dli_02_0108__sba3aea1255394b83a6b44b56d1443424"><h4 class="sectiontitle">Request</h4><p id="dli_02_0108__p41026741152339">None</p>
</div>
<div class="section" id="dli_02_0108__s3b91e8001c304b1fab9451feec878c3e"><h4 class="sectiontitle">Response</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_02_0108__en-us_topic_0069077903_table27982971" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Response parameters</caption><thead align="left"><tr id="dli_02_0108__en-us_topic_0069077903_row46534355"><th align="left" class="cellrowborder" valign="top" width="11.1%" id="mcps1.3.4.2.2.5.1.1"><p id="dli_02_0108__a8492bb7ea9aa47d1a50c3370cc8fd80c">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="12.690000000000001%" id="mcps1.3.4.2.2.5.1.2"><p id="dli_02_0108__p134002501736">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="19.09%" id="mcps1.3.4.2.2.5.1.3"><p id="dli_02_0108__ad5d73f500bd941708658fac31c1a15cb">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="57.120000000000005%" id="mcps1.3.4.2.2.5.1.4"><p id="dli_02_0108__en-us_topic_0069077903_p669144151612">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_02_0108__en-us_topic_0069077903_row48222793"><td class="cellrowborder" valign="top" width="11.1%" headers="mcps1.3.4.2.2.5.1.1 "><p id="dli_02_0108__en-us_topic_0069077903_p13732189">is_success</p>
</td>
<td class="cellrowborder" valign="top" width="12.690000000000001%" headers="mcps1.3.4.2.2.5.1.2 "><p id="dli_02_0108__p9400850732">No</p>
</td>
<td class="cellrowborder" valign="top" width="19.09%" headers="mcps1.3.4.2.2.5.1.3 "><p id="dli_02_0108__en-us_topic_0069077903_p36799834">Boolean</p>
</td>
<td class="cellrowborder" valign="top" width="57.120000000000005%" headers="mcps1.3.4.2.2.5.1.4 "><p id="dli_02_0108__p1096242814143">Whether the request is successfully executed. Value <span class="parmvalue" id="dli_02_0108__parmvalue5716630816104"><b>true</b></span> indicates that the request is successfully executed.</p>
</td>
</tr>
<tr id="dli_02_0108__en-us_topic_0069077903_row50642479"><td class="cellrowborder" valign="top" width="11.1%" headers="mcps1.3.4.2.2.5.1.1 "><p id="dli_02_0108__en-us_topic_0069077903_p8400114">message</p>
</td>
<td class="cellrowborder" valign="top" width="12.690000000000001%" headers="mcps1.3.4.2.2.5.1.2 "><p id="dli_02_0108__p134001150234">No</p>
</td>
<td class="cellrowborder" valign="top" width="19.09%" headers="mcps1.3.4.2.2.5.1.3 "><p id="dli_02_0108__en-us_topic_0069077903_p16771545">String</p>
</td>
<td class="cellrowborder" valign="top" width="57.120000000000005%" headers="mcps1.3.4.2.2.5.1.4 "><p id="dli_02_0108__p3962132820148">System prompt. If execution succeeds, the parameter setting may be left blank.</p>
</td>
</tr>
<tr id="dli_02_0108__en-us_topic_0069077903_row12643388"><td class="cellrowborder" valign="top" width="11.1%" headers="mcps1.3.4.2.2.5.1.1 "><p id="dli_02_0108__p5559186215158">schema</p>
</td>
<td class="cellrowborder" valign="top" width="12.690000000000001%" headers="mcps1.3.4.2.2.5.1.2 "><p id="dli_02_0108__p164017506318">No</p>
</td>
<td class="cellrowborder" valign="top" width="19.09%" headers="mcps1.3.4.2.2.5.1.3 "><p id="dli_02_0108__p153721315158">Array of objects</p>
</td>
<td class="cellrowborder" valign="top" width="57.120000000000005%" headers="mcps1.3.4.2.2.5.1.4 "><p id="dli_02_0108__p5740541315158">Column name and type of a table.</p>
</td>
</tr>
<tr id="dli_02_0108__en-us_topic_0069077903_row59937243"><td class="cellrowborder" valign="top" width="11.1%" headers="mcps1.3.4.2.2.5.1.1 "><p id="dli_02_0108__p3972395415158">rows</p>
</td>
<td class="cellrowborder" valign="top" width="12.690000000000001%" headers="mcps1.3.4.2.2.5.1.2 "><p id="dli_02_0108__p114014501530">No</p>
</td>
<td class="cellrowborder" valign="top" width="19.09%" headers="mcps1.3.4.2.2.5.1.3 "><p id="dli_02_0108__p4514657515158">Array of objects</p>
</td>
<td class="cellrowborder" valign="top" width="57.120000000000005%" headers="mcps1.3.4.2.2.5.1.4 "><p id="dli_02_0108__p3299394415158">Previewed table content.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="dli_02_0108__section1835742415112"><h4 class="sectiontitle">Example Request</h4><p id="dli_02_0108__p810253431112">None</p>
</div>
<div class="section" id="dli_02_0108__section41378223152310"><h4 class="sectiontitle">Example Response</h4><div class="p" id="dli_02_0108__p890043810123">The following is an example of a successful response in synchronous mode:<pre class="screen" id="dli_02_0108__screen28241106152330">{
"is_success": true,
"message": "",
"schema": [
{
"id": "int"
},
{
"name": "string"
},
{
"address": "string"
}
],
"rows": [
[
"1",
"John",
"xxx"
],
[
"2",
"Lily",
"xxx"
]
]
}</pre>
<div class="note" id="dli_02_0108__note21113357171028"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dli_02_0108__p1650845524511">In asynchronous request mode, a job ID is returned. You can obtain the preview information based on the job ID.</p>
</div></div>
</div>
</div>
<div class="section" id="dli_02_0108__sf39cfd445ad24e9e82754fcb0027179d"><h4 class="sectiontitle">Status Codes</h4><p id="dli_02_0108__a04144ca3a08e4576b386c6a98f43a2ae"><a href="#dli_02_0108__tb12870f1c5f24b27abd55ca24264af36">Table 4</a> describes the status code.</p>
<div class="tablenoborder"><a name="dli_02_0108__tb12870f1c5f24b27abd55ca24264af36"></a><a name="tb12870f1c5f24b27abd55ca24264af36"></a><table cellpadding="4" cellspacing="0" summary="" id="dli_02_0108__tb12870f1c5f24b27abd55ca24264af36" frame="border" border="1" rules="all"><caption><b>Table 4 </b>Status codes</caption><thead align="left"><tr id="dli_02_0108__r8d54231f95b14c01a5e55e95f3b2e838"><th align="left" class="cellrowborder" valign="top" width="30%" id="mcps1.3.7.3.2.3.1.1"><p id="dli_02_0108__ab49d21f312644072a331f43e92baf853">Status Code</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="70%" id="mcps1.3.7.3.2.3.1.2"><p id="dli_02_0108__aea1d3bd107bb4c499da79a88832d256c">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_02_0108__r211ad4eb571d4d938e5579998723174e"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.7.3.2.3.1.1 "><p id="dli_02_0108__a3153e07b3a9749adba92599fe6628fbf">200</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.7.3.2.3.1.2 "><p id="dli_02_0108__p104431642124811">The query is successful.</p>
</td>
</tr>
<tr id="dli_02_0108__row44937531727"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.7.3.2.3.1.1 "><p id="dli_02_0108__p184941532219">400</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.7.3.2.3.1.2 "><p id="dli_02_0108__p2049413539219">Request error.</p>
</td>
</tr>
<tr id="dli_02_0108__row65331212142411"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.7.3.2.3.1.1 "><p id="dli_02_0108__p5537171216249">500</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.7.3.2.3.1.2 "><p id="dli_02_0108__p953813124249">Internal service error.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="dli_02_0108__section13596141025715"><h4 class="sectiontitle">Error Codes</h4><p id="dli_02_0108__p420584425712">If an error occurs when this API is invoked, the system does not return the result similar to the preceding example, but returns the error code and error information. For details, see <a href="dli_02_0056.html">Error Codes</a>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_02_0031.html">Table-related APIs</a></div>
</div>
</div>