I want to create a procedure which when I call creates a backup by creating an .sql file and saves it in my computer.
The procedure's name is trial_gen(). When I execute call trial_gen(), it should create a plain .sql file of the schema.
All solutions I found were only using the SQL shell
pg_dump, why do you want this to work as a query in pgAdmin? It's possible to get DDL statements for everything from system tables and spit it out throughCOPYinto an .sql file on your drive (assuming it's a local database), but you'll either have to settle for a subset of your relations, or re-invent a slower, pure-SQLpg_dump. pgAdmin already offers a backup and restore dialog, that's basically a GUI forpg_dump.