20.2. Running an Arbitrary Command in DuckDB (axe.raw_query) #
The axe.raw_query stored procedure can execute any command, not just SELECT. Unlike the axe.query stored procedure, axe.raw_query does not return the result as rows. The result is sent to the server logs. It is recommended to use the axe.query stored procedure when possible.
Required privileges: Superuser or the Postgres Pro AXE administrator.
For more information about access management, refer to Chapter 12.
Execute the following command on the Postgres Pro AXE server:
SELECT axe.raw_query('command');
Where command is the command that must be executed.
Postgres Pro AXE will execute the specified command directly against DuckDB.
Example 20.2. Running an Arbitrary Command in DuckDB
Creating a table in DuckDB:
SELECT axe.raw_query('CREATE TABLE employees (id INTEGER, name VARCHAR, salary DECIMAL)');
Inserting rows into the table:
SELECT axe.raw_query('INSERT INTO employees VALUES (1, ''Alice'', 50000), (2, ''Bob'', 60000)');
Updating a row in the table:
SELECT axe.raw_query('UPDATE employees SET salary = 55000 WHERE id = 1');
Deleting a row from the table:
SELECT axe.raw_query('DELETE FROM employees WHERE id = 2');
Dropping the table:
SELECT axe.raw_query('DROP TABLE employees');
You can also use the axe.raw_query stored procedure to create and delete DuckDB macros.