This topic describes how to write, configure, and run an SQL script in MaxCompute Studio.
Prerequisites
A MaxCompute project is connected. For more information, see Manage project connections.
A MaxCompute script module is created. For more information, see Create a MaxCompute script module.
Write an SQL script
In the Project tool window, click a project name, right-click scripts, and then choose New > MaxCompute SQL Script.

In the New MaxCompute SQL Script dialog box, configure the following parameters, and then click OK.

Script Name: the name of the script.
MaxCompute Project: the MaxCompute project in which to write the SQL script. Click + to connect to another MaxCompute project. For more information, see Manage project connections.
Write an SQL script in the editor. For more information about SQL syntax, see Overview of MaxCompute SQL. Sample script: Note:
Cross-project resource sharing is supported. For example, a script bound to Project A can access table1 in Project B.
MaxCompute Studio allows you to configure the SQL script editor. For more information, see Overview.
CREATE TABLE table_5( col1 BIGINT, col2 BIGINT, col3 BIGINT, ds DATETIME ); INSERT INTO TABLE table_5 VALUES (1, 2,3,DATETIME'2025-11-11 00:00:00'); SELECT * FROM table_5 WHERE ds='${bizdate}';
Configure compilation parameters
Before submitting an SQL script, configure the compilation parameters in the toolbar above the editor.
Editor mode
| Option | Description |
|---|---|
| Statement Mode | Separates SQL statements with semicolons (;) and submits each statement individually to the MaxCompute server. |
| Script Mode (Recommended) | Submits the entire script to the MaxCompute server at once for overall optimization. This is the latest development mode and provides better execution efficiency. |
Type system
Configure this parameter to prevent compatibility issues when running SQL statements.
| Option | Description |
|---|---|
| Legacy TypeSystem | MaxCompute V1.0 data type edition. |
| MaxCompute TypeSystem | MaxCompute V2.0 data type edition. |
| Hive Compatible TypeSystem | Hive-compatible data type edition. |
Execution mode
| Option | Description |
|---|---|
| Default Version | Uses a stable version. |
| MaxQA | Enables the MaxQA feature to run a job. |
| MaxCompute Query Acceleration | Enables the MaxCompute Query Acceleration (MCQA) feature to run a job. |
| Rerun When Acceleration Fails | Reruns a job if query acceleration fails. |
Run the script
In the toolbar or sidebar, click the
icon to submit the SQL script to the MaxCompute server.If the SQL script contains a variable such as
${bizdate}, a dialog box prompts for the variable value. For example, enter2017-11-11 00:00:00to query data in the corresponding partition.Review the estimated cost that IntelliJ IDEA displays, and then click OK in the Confirmation message.
Note:To update the metadata used in the SQL script, such as tables and user-defined functions (UDFs), click the
icon in the toolbar. Use this if MaxCompute Studio cannot detect the tables and functions in MaxCompute.SQL scripts are compiled based on the metadata added in the Project Explorer window. If no errors are detected, the scripts are submitted to the MaxCompute server for execution.
Run logs are generated during execution. When SQL scripts run in MaxCompute, the job details tab appears with execution details.
To display cost estimation for SQL jobs, select Show sql cost confirm dialog when script submitted in the MaxCompute SQL configuration items.
On the Result tab, view the execution results. If multiple statements are executed one by one, the result of each statement is displayed separately.
