By using OSS Select, you can use simple SQL statements to select content from an object in OSS to obtain only required data. This way, OSS Select reduces the amount of data transmitted from OSS to improve the data retrieval efficiency.
- OSS Select supports UTF-8 encoded CSV objects and JSON objects. Supported CSV objects and CSV-like objects such as TSV objects must conform to RFC 4180. You can customize row and column delimiters and quote characters in CSV objects.
- You can select and obtain a maximum of 40 MB of data from an object that does not exceed 128 MB in the OSS console. To process an object larger than 128 MB or to retrieve more records, call SelectObject.
- Log on to the OSS console.
- Click Buckets, and then click the name of the target bucket.
- Click the Files tab.
- Choose in the Actions column corresponding to the target object.
- In the Select Content dialog box that appears, set the following parameters:
- File Type: Select an object format as required. Valid values: CSV and JSON.
- Delimiter: Set this parameter for CSV objects. Valid values: comma (,) and Custom.
- Title Line: Set this parameter for CSV objects. You can configure this option to specify whether the first row of the object contains a column heading.
- JSON Display Mode: Select the display mode for JSON objects.
- Compression Format: Specify whether to compress the current object. Currently, only GZIP-based compression is supported.
- Click Preview to preview the object.
Note Fees are incurred when you preview an object that is scanned by using OSS Select.
- Standard: Fees are incurred when you preview an object that is scanned by using OSS Select.
- IA, Archive, and Cold Archive: Fees are incurred when you preview an object that is scanned by using OSS Select and data retrieval.
- Click Next Step. Enter and execute an SQL statement.
- View the execution results. Click Download to download the selected content to the local device.
- To query people who are above 50 years old and whose names start with string Lora,
execute the following SQL statement. In the statement, _1, _2, and _3 specify column
indexes. _1 specifies the index of the first column. _2 specifies the index of the
second column. _3 specifies the index of the third column.
select * from ossobject where _1 like 'Lora*' and _3 > 50
- To query the count of rows in the object, maximum age, and minimum age, execute the
following SQL statement:
select count(*), max(cast(_3 as int)), min(cast(_3 as int)) from ossobject