【单选题】关于以下 SQL 语句描述正确的选项是?ALTER SYSTEM SET work_mem TO DEFAULT

  • work_mem 参数将被添加到 kingbase.auto.conf 中
  • kingbase.auto.conf 中的 work_mem 参数将被移除
  • work_mem 参数将被添加到 kingbase.conf 中
  • 提示报错:没有此命令

解题思路:

简单粗暴,直接执行:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
-- 查看 kingbase.auto.conf 文件内容
test=# \! cat /data/kingbase.auto.conf
# Do not edit this file manually!
# It will be overwritten by the ALTER SYSTEM command.

-- 查看当前参数值
test=# show work_mem;
work_mem
----------
4MB
(1 行记录)

-- 执行命令,此时没有任何变化
test=# ALTER SYSTEM SET work_mem TO DEFAULT;
ALTER SYSTEM
test=# show work_mem;
work_mem
----------
4MB
(1 行记录)

test=# \! cat /data/kingbase.auto.conf
# Do not edit this file manually!
# It will be overwritten by the ALTER SYSTEM command.

-- 先手动设置 work_mem 参数值并加载参数值,此时 conf 文件中有了 work_mem 参数的配置
test=# alter system set work_mem='8MB';
ALTER SYSTEM
test=# show work_mem;
work_mem
----------
4MB
(1 行记录)

test=# \! sys_ctl reload
服务器进程发出信号
test=# show work_mem;
work_mem
----------
8MB
(1 行记录)

test=# \! cat /data/kingbase.auto.conf
# Do not edit this file manually!
# It will be overwritten by the ALTER SYSTEM command.
work_mem = '8MB'

再次执行命令 to default:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
test=# ALTER SYSTEM SET work_mem TO DEFAULT;
ALTER SYSTEM
test=# show work_mem;
work_mem
----------
8MB
(1 行记录)

test=# \! cat /data/kingbase.auto.conf
# Do not edit this file manually!
# It will be overwritten by the ALTER SYSTEM command.

test=# \! sys_ctl reload
服务器进程发出信号
test=# show work_mem;
work_mem
----------
4MB
(1 行记录)

由上可见,work_mem 配置从 kingbase.auto.conf 中消失了,所以 to default 操作是用来清空 conf 文件中对应参数的配置。