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.
Prerequisites
- 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.
Procedure
Example
For example, an object named People contains the following columns: Name, Company, and Age.
- 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