Data
The following operations can be performed on the SQL queries against the BD server:
GET /data
This API is used to execute a SQL query against the BD server. Queries issued for previewing data must be composite SQL queries i.e., non-standard.Returns a set of tuples in a 2-dimensional JSON array: [[row1col1value, row1col2value], [row2col1value, row2col2value]].
Parameters
Name | Description | Parameter Type | Data Type |
query | Contains the sql statement. Proper URL encoding is required | query | string |
standardSQL | If true, then SQL is standard. If false, then Composite SQL is assumed. Default = true. | query | boolean |
system | If true, query is assumed to be a system query. If false, then query is for previewing data. Default = true. | query | boolean |
Example to query a system table
curl -X GET -u admin:admin "https://localhost:9502/rest/v2/data?q=select+1%2C+2%2C+%27yo%27%2C+date+%272002-2-2%27"
SQL: select 1, 2, 'yo', date '2002-2-2'
Example to Query a system table (as ldap user)
curl -X GET -u user@ldapDomain:password "https://localhost:9502/rest/v2/data?q=select+1%2C+2%2C+%27yo%27%2C+date+%272002-2-2%27"
SQL: select 1, 2, 'yo', date '2002-2-2'
Example to Preview data from a published database table.
curl -X GET -u admin:admin "https://localhost:9502/rest/v2/data?q=select+%2A+from+%2Flocalhost_9400%2Fservices%2Fdatabases%2Ftutorial%2Forders&standardSQL=false&system=false"
SQL: select * from /localhost_9400/services/databases/tutorial/orders
GET /data/query
This API is used to execute a SQL query against the BD server. Queries issued for previewing data must be composite SQL queries i.e., non-standard.Returns a set of tuples in a 2-dimensional JSON array: [[row1col1value, row1col2value], [row2col1value, row2col2value]].
Parameters
Name | Description | Parameter Type | Data Type |
query | Contains the sql statement. Proper URL encoding is required | header | string |
standardSQL | If true, then SQL is standard. If false, then Composite SQL is assumed. Default = true. | header | boolean |
system | If true, query is assumed to be a system query. If false, then query is for previewing data. Default = true. | header | boolean |
Example to query a system table
curl -X GET -u admin:admin "https://localhost:9502/rest/v2/data/query" --header "query:select 1, 2, 'yo', date '2002-2-2'"
Example to Query a system table (as ldap user)
curl -X GET -u user@ldapDomain:password "https://localhost:9502/rest/v2/data/query" --header "query:select 1, 2, 'yo', date '2002-2-2'"
Example to Preview data from a published database table.
curl -X GET -u admin:admin "https://localhost:9502/rest/v2/data/query" -H "query:select * from /localhost_9400/services/databases/tutorial/orders" -H "standardSQL:false" -H "system:false"
POST /data/typed
This API is used to execute a SQL query against the BD server. Returns a set of tuples in a 2-dimensional JSON array: [[row1col1value, row1col2value], [row2col1value, row2col2value]].
Parameters
Name | Description | Parameter Type | Data Type |
body | Contains the sql statement, an optional 'standardSQL' flag that defaults to true and an optional 'isSystem' flag that defaults to true. Set the 'standardSQL' and 'isSystem' flags to false for performing a data preview, as the data preview query must be a composite query i.e., non-standard. | body | Modelschema |
Request Body
{
"standardSQL": true,
"query": "string",
"system": true
}
Example to query a system table
curl -X POST -u admin:admin "https://localhost:9502/rest/v2/data/typed" -H "Content-Type:application/json" -d '{"query":"SELECT * from ALL_COMMENTS","standardSQL":true}'
Example to Query a system table (as ldap user)
curl -X POST -u user@ldapDomain:password "https://localhost:9502/rest/v2/data/typed" -H "Content-Type:application/json" -d '{"query":"SELECT * from ALL_COMMENTS","standardSQL":true}'
Example to Preview data from a published database table.
curl -X POST -u admin:admin "https://localhost:9502/rest/v2/data/typed" -H "Content-Type:application/json" -d "{\"query\":\"SELECT * from /localhost_9400/services/databases/tutorial/orders\",\"standardSQL\":false,\"system\":false}"