Configuration parameters

Add a line to the end of the configurations file:

postgres$ echo 'work_mem = 8MB' >> /etc/postgresql/11/alpha/postgresql.conf

Reload configuration:

student$ sudo pg_ctlcluster 11 alpha reload

Let's check:

α=> SELECT current_setting('work_mem') AS work_mem;
 work_mem 
----------
 8MB
(1 row)

Executing scripts

Write CREATE TABLE and INSERT commands into a file (this can be accomplished with any text editor of choice):

student$ echo 'CREATE TABLE keywords (' >script.sql
student$ echo '    word text,' >>script.sql
student$ echo '    category text,' >>script.sql
student$ echo '    description text' >>script.sql
student$ echo ');' >>script.sql
student$ echo 'INSERT INTO keywords SELECT * FROM pg_get_keywords();' >>script.sql

What is in the file:

student$ cat script.sql
CREATE TABLE keywords (
    word text,
    category text,
    description text
);
INSERT INTO keywords SELECT * FROM pg_get_keywords();

Now run psql, execute scripts, and verify the result:

α=> \i script.sql
CREATE TABLE
INSERT 0 440
α=> SELECT * FROM keywords LIMIT 10;
   word    | category | description 
-----------+----------+-------------
 abort     | U        | unreserved
 absolute  | U        | unreserved
 access    | U        | unreserved
 action    | U        | unreserved
 add       | U        | unreserved
 admin     | U        | unreserved
 after     | U        | unreserved
 aggregate | U        | unreserved
 all       | R        | reserved
 also      | U        | unreserved
(10 rows)

A look into the message log

postgres$ tail -n 2 /var/log/postgresql/postgresql-11-alpha.log
2019-02-27 15:38:46.193 MSK [19253] LOG:  received SIGHUP, reloading configuration files
2019-02-27 15:38:46.194 MSK [19253] LOG:  parameter "work_mem" changed to "8MB"