keep_user_target_list_in_result Keep the query result set column name consistent with the user’s specified case

In MatrixOne query, keeping the result set column name consistent with the user-specified name size, in addition to using alias, it can also be achieved by setting parameters.

keep_user_target_list_in_result is a global parameter that sets the query result set column name consistent with the name specified by the user.

Check keep_user_target_list_in_result

Use the following command in MatrixOne to view keep_user_target_list_in_result:

SQL
--Default is 1
show variables like "keep_user_target_list_in_result";
select @@keep_user_target_list_in_result;

Set keep_user_target_list_in_result

Set keep_user_target_list_in_result in MatrixOne using the following command:

SQL
--Default is 1, reconnection to the database takes effect
set global keep_user_target_list_in_result = 0;

Example

Text
create table t1(aa int, bb int, cc int, AbC varchar(25), A_BC_d double);
insert into t1 values (1,2,3,'A',10.9);

mysql> select * from t1;
+----+----+----+-----+--------+
| aa | bb | cc | abc | a_bc_d |
+----+----+----+-----+--------+
| 1  | 2  | 3  | A   | 10.9   |
+----+----+----+-----+--------+
1 row in set (0.00 sec)

mysql> select @@keep_user_target_list_in_result; --Query parameter value, enabled by default
+-----------------------------------+
| @@keep_user_target_list_in_result |
+-----------------------------------+
| 1                                 |
+-----------------------------------+
1 row in set (0.01 sec)

mysql> select aA, bB, CC, abc, a_Bc_D from t1;--When enabled, the column name of the query result set is consistent with the name specified by the user
+----+----+----+-----+--------+
| aA | bB | CC | abc | a_Bc_D |
+----+----+----+-----+--------+
| 1  | 2  | 3  | A   | 10.9   |
+----+----+----+-----+--------+
1 row in set (0.00 sec)

mysql> set global keep_user_target_list_in_result =0;--Close the query result set column name and the user-specified name setting
Query OK, 0 rows affected (0.01 sec)

mysql> exit;--The parameters take effect after exiting the database and reconnecting

mysql> show variables like "keep_user_target_list_in_result";
+---------------------------------+-------+
| Variable_name                   | Value |
+---------------------------------+-------+
| keep_user_target_list_in_result | 0     |
+---------------------------------+-------+
1 row in set (0.00 sec)

mysql> select aA, bB, CC, abc, a_Bc_D from t1;--In the setting off, the column name of the query result set is inconsistent with the name specified by the user
+----+----+----+-----+--------+
| aa | bb | cc | abc | a_bc_d |
+----+----+----+-----+--------+
| 1  | 2  | 3  | A   | 10.9   |
+----+----+----+-----+--------+
1 row in set (0.00 sec)
Last updated on