All Products
Search
Document Center

PolarDB:Connect to a cluster by using a cluster endpoint and execute an AI SQL statement

Last Updated:Mar 25, 2024

This topic describes how to connect to a cluster to use the PolarDB for AI feature and the requirements for SQL statements.

Connect to a cluster by using a cluster endpoint

To use the PolarDB for AI feature, you must connect to the cluster endpoint of a PolarDB cluster instead of the primary endpoint when you connect to the cluster over Data Management (DMS), from a client or by using the command line. For more information, see Use DMS to connect to a cluster, Use a client to connect to a cluster, and Use the CLI to connect to a cluster.

Note
mysql -h localhost -u username -p password -c

DMS uses the primary endpoint by default. Therefore, if you connect to a cluster by using DMS, you must perform the following steps to connect to the cluster by using the cluster endpoint. For more information, see Use DMS to connect to a cluster.

  1. After you connect to a cluster over DMS, choose Database Instance > Instances Connected in the left-side navigation pane. Then, right-click the cluster and select Edit. image.png

  2. Change Entry mode to Connection string address and enter the cluster endpoint of the cluster. image.png

  3. Click Save.

Requirements for AI SQL statements

SQL statements that support the features and models of PolarDB for AI are collectively referred to as the extended SQL statements of PolarDB (AI SQL statements).

When you execute an AI SQL statement, you must add /*polar4ai*/ before the SQL statement. The SQL statements executed by the current Alibaba Cloud account are added to audit logs.

Example:

/*polar4ai*/create feature test_graph_1 with (feature_class='graph') as (select ip, user_id from small_sample limit 30);

For more information about the usage of AI SQL statements, see the documentation of the PolarDB for AI features, such as Model management and Advanced usage.