AI-generated SQL

Updated at:

The AI-generated SQL feature uses the artificial intelligence generated content (AIGC) capability of Alibaba Cloud Model Studio to automatically generate SQL statements from your natural language descriptions. You can use this feature in the advanced search section of the Resource Center to query resources within your current account or across multiple accounts. This improves your search experience and efficiency.

Limits

Each Alibaba Cloud account can use this feature up to 100 times per day.

Procedure

  1. Log on to the Resource Center console.

  2. In the navigation pane on the left, choose Resource Center > Advanced Search.

  3. On the right side of the page, click AI-generated SQL.

    You can also use the keyboard shortcut Ctrl+I in the query window to enable the AI-generated SQL feature.

  4. In the AI-generated SQL dialog box, enter a query description in natural language. Then, click Generate.

    • Examples of resource property queries

      • Find resources where the tag key is 'project' and the tag value is 'test'.

      • Find ECS instances that are in the Stopped state.

      • Find RDS instances that use the MySQL database with engine version 8.0.

      • Find resources whose names start with 'test'.

    • Examples of resource statistics queries

      • Count resources and group them by resource type.

      • Find resources created in December 2023.

    • Examples of associated resource queries

      • Find disks associated with an ECS instance.

      • Find network interface cards associated with an ECS instance.

      • Find images associated with an ECS instance.

    Note

    To improve accuracy, provide precise and detailed descriptions. For example, a query for 'recently created resources' is vague because the system cannot determine the exact time range. For resource property queries, use the property names listed in the resource properties section on the left side of the console. This helps the system understand your intent and generate more accurate results.

  5. Review the auto-generated SQL statement. Then, click Overwrite Existing Query or Open New Query.

    • Overwrite Existing Query: Replaces the content in the current query window with the generated SQL statement.

    • Open New Query: Opens a new query window and populates it with the generated SQL statement.

    Note

    The AI-generated SQL feature uses artificial intelligence, and the generated SQL statements are for reference only. Although the feature is designed for accuracy, the results are not guaranteed to be error-free. If you encounter any issues or have questions, click Submit Feedback. We are always working to improve our services.

  6. In the query window, click Run.

    You can also edit the SQL statement or save it as a query template.

  7. View the query results.

    If the results meet your expectations, you can save the query as a custom query template for reuse. Otherwise, you can try providing a more precise prompt to the AI or submit feedback.

References