Manage listings with SQL as a consumer - examples¶
The following are examples of the common tasks that consumers can complete programmatically with SQL commands:
Show available listings¶
Shows the listings available to the consumer running the command. For more information about the SHOW AVAILABLE LISTINGS command, see SHOW AVAILABLE LISTINGS.
Description |
Notes |
|---|---|
Show the available listings. |
Use |
Describe available listings¶
After running SHOW AVAILABLE LISTINGS to identify the available listings and the global listing names, a consumer can run DESCRIBE AVAILABLE LISTING to return descriptions of the columns in the listings that are available to them. For more information about the DESCRIBE AVAILABLE LISTING command, see DESCRIBE AVAILABLE LISTING.
Description |
Notes |
|---|---|
Describe the listing columns. |
Use |
Request a listing and automatically poll for availability¶
After running SHOW AVAILABLE LISTINGS to identify the available listings, a consumer can use the SYSTEM$REQUEST_LISTING_AND_WAIT stored procedure to request a listing and automatically poll for availability. A consumer can also use this stored procedure when the is_ready_for_import column is FALSE. For more information about the SYSTEM$REQUEST_LISTING_AND_WAIT stored procedure, see SYSTEM$REQUEST_LISTING_AND_WAIT.
Description |
Notes |
|---|---|
Request a specific listing and poll for availability. |
When a requested listing becomes available or is already available, the message If the timeout period is exceeded, the message To request a listing without waiting for listing fulfillment, enter 0 (zero) for the |
Create a database from a listing¶
After requesting a listing, a consumer can use the CREATE DATABASE … FROM LISTING … command to create a database from a listing. For more information about the CREATE DATABASE … FROM LISTING … command, see CREATE DATABASE … FROM LISTING ….
Description |
Notes |
|---|---|
Create a database from a listing. |
|
End-to-end example¶
The following example shows how to use the SQL commands described above to manage listings as a consumer. The example assumes that the consumer has already been granted access to a listing for COVID-19 data named GZ1MXZFTF1 and that the listing is available in the consumer’s region. The example also assumes that the consumer has been granted the sysadmin role, which is required to create a database from a listing.