{"id":43416,"date":"2022-12-07T12:30:38","date_gmt":"2022-12-07T18:30:38","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=43416"},"modified":"2022-12-28T04:39:28","modified_gmt":"2022-12-28T10:39:28","slug":"10-useful-and-practical-postgresql-commands","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/","title":{"rendered":"10 Useful and Practical PostgreSQL Commands"},"content":{"rendered":"<div id=\"bsf_rt_marker\"><\/div><p><img decoding=\"async\" class=\"alignnone size-full wp-image-43638\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/11\/useful-and-practical-postgresql-commands.webp\" alt=\"useful and practical postgresql commands\" width=\"742\" height=\"372\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/11\/useful-and-practical-postgresql-commands.webp 742w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/11\/useful-and-practical-postgresql-commands-300x150.webp 300w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/11\/useful-and-practical-postgresql-commands-150x75.webp 150w\" sizes=\"(max-width: 742px) 100vw, 742px\" \/><\/p>\n<p>In this tutorial, we are going to explain ten useful and practical PostgreSQL commands in Linux.<\/p>\n<p>PostgreSQL is a very powerful object-relational database management system. It is SQL complained designed to handle many concurrent users and a range of workloads. PostgreSQL is compatible with different operating systems such as macOS, Windows, FreeBSD, and Linux, which this blog post will explain.<\/p>\n<p>We will install <a href=\"https:\/\/www.rosehosting.com\/ubuntu-hosting\/\">PostgreSQL on Ubuntu 22.04<\/a>, but you can choose any Linux distro you want. Let&#8217;s get started!<\/p>\n<p><!--more--><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69cc8ff46fcef\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69cc8ff46fcef\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#Prerequisites\" >Prerequisites<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#Update-the-System\" >Update the System<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#PostgreSQL-Installation\" >PostgreSQL Installation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#1-Log-in-to-PostgreSQL\" >1. Log in to PostgreSQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#2-List-databases\" >2. List databases<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#3-Get-the-size-of-the-Database\" >3. Get the size of the Database<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#4-List-Users-and-assigned-Roles\" >4. List Users and assigned Roles<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#5-Creating-Database-and-User-in-PostgreSQL\" >5. Creating Database and User in PostgreSQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#6-Connect-to-the-database-with-the-assigned-User\" >6. Connect to the database with the assigned User<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#7-Change-the-Password-of-the-User\" >7. Change the Password of the User<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#8-Reload-PostgreSQL-Configuration\" >8. Reload PostgreSQL Configuration<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#9-Check-the-PostgreSQL-version\" >9. Check the PostgreSQL version<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#10-Exit-the-PostgreSQL-command-line\" >10. Exit the PostgreSQL command line<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Prerequisites\"><\/span>Prerequisites<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>Fresh install of Ubuntu 22.04<\/li>\n<li>User privileges: root or non-root user with sudo privileges<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Update-the-System\"><\/span>Update the System<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Every fresh installation of Ubuntu 22.04 needs a system update. To update the system packages execute the following commands.<\/p>\n<pre>sudo apt update -y &amp;&amp; sudo apt upgrade -y<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"PostgreSQL-Installation\"><\/span>PostgreSQL Installation<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To install PostgreSQL execute the following command:<\/p>\n<pre>sudo apt install postgresql -y<\/pre>\n<p>Once installed, start and enable the PostgreSQL service:<\/p>\n<pre>systemctl start postgresql.service &amp;&amp; systemctl enable postgresql.service<\/pre>\n<p>To check the status of the service:<\/p>\n<pre>systemctl status postgresql.service<\/pre>\n<p>If everything is ok, you should get the following output:<\/p>\n<pre>root@host:~# systemctl status postgresql.service\r\n\u25cf postgresql.service - PostgreSQL RDBMS\r\n     Loaded: loaded (\/lib\/systemd\/system\/postgresql.service; enabled; vendor preset: enabled)\r\n     Active: active (exited) since Tue 2022-10-18 17:22:36 CDT; 38s ago\r\n   Main PID: 307278 (code=exited, status=0\/SUCCESS)\r\n        CPU: 3ms\r\n\r\nOct 18 17:22:36 host.test.vps systemd[1]: Starting PostgreSQL RDBMS...\r\nOct 18 17:22:36 host.test.vps systemd[1]: Finished PostgreSQL RDBMS.\r\n<\/pre>\n<p>Now, when the PostgreSQL database service is installed, we can start with the <b>PostgreSQL<\/b> commands.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"1-Log-in-to-PostgreSQL\"><\/span>1. Log in to PostgreSQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To log in to the PostgreSQL admin command line, execute the following command:<\/p>\n<pre>sudo -u postgres psql<\/pre>\n<p>Once logged in, you should receive the following output:<\/p>\n<pre>root@host:~# sudo -u postgres psql\r\ncould not change directory to \"\/root\": Permission denied\r\npsql (14.5 (Ubuntu 14.5-0ubuntu0.22.04.1))\r\nType \"help\" for help.\r\n\r\npostgres=#<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"2-List-databases\"><\/span>2. List databases<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To list the database in Postgres, execute the following command:<\/p>\n<pre>\\l<\/pre>\n<p>It is a simple command <b>\\l<\/b> which will retrieve all databases in a table like this:<\/p>\n<pre>postgres=# \\l\r\n                                  List of databases\r\n   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges\r\n-----------+----------+----------+-------------+-------------+-----------------------\r\n postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |\r\n template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c\/postgres          +\r\n           |          |          |             |             | postgres=CTc\/postgres\r\n template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c\/postgres          +\r\n           |          |          |             |             | postgres=CTc\/postgres\r\n(3 rows)\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"3-Get-the-size-of-the-Database\"><\/span>3. Get the size of the Database<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To get the size of the <b>postgres<\/b> database, you need to connect to it first. To do that, execute the following command:<\/p>\n<pre>\\c postgres<\/pre>\n<p>Once connected, you should receive the following output:<\/p>\n<pre>postgres=# \\c postgres\r\nYou are now connected to database \"postgres\" as user \"postgres\".<\/pre>\n<p>Now, we can check the size of the current (postgres) database<\/p>\n<pre>SELECT pg_database_size(current_database());<\/pre>\n<p>This will return the size in bytes<\/p>\n<pre>postgres=# SELECT pg_database_size(current_database());\r\n pg_database_size\r\n------------------\r\n          8774435\r\n(1 row)<\/pre>\n<p>If you want the output to be in the human-readable format in Kilobytes, Megabytes, or Gigabytes execute the following command:<\/p>\n<pre>select pg_size_pretty(pg_database_size(current_database()));<\/pre>\n<p>Now, the output should look like this:<\/p>\n<pre> pg_size_pretty\r\n----------------\r\n 8569 kB\r\n(1 row)<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"4-List-Users-and-assigned-Roles\"><\/span>4. List Users and assigned Roles<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To list the users and their assigned roles, execute the following command:<\/p>\n<pre>\\du<\/pre>\n<p>You should receive the table as output with the PostgreSQL user and its privileges as described below:<\/p>\n<pre>postgres=# \\du\r\n                                   List of roles\r\n Role name |                         Attributes                         | Member of\r\n-----------+------------------------------------------------------------+-----------\r\n postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"5-Creating-Database-and-User-in-PostgreSQL\"><\/span>5. Creating Database and User in PostgreSQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To create a new database in PostgreSQL, execute the following command:<\/p>\n<pre>create database testdb;<\/pre>\n<p>Once the database is created, you will receive the following output:<\/p>\n<pre>postgres=# create database testdb;\r\nCREATE DATABASE\r\n<\/pre>\n<p>To create a new user with a password, execute the following command:<\/p>\n<pre>CREATE USER testuser WITH ENCRYPTED PASSWORD 'StrongPasswordHere';<\/pre>\n<p>Once the user is created, you will receive the following output:<\/p>\n<pre>postgres=# CREATE USER rosehosting WITH ENCRYPTED PASSWORD 'StrongPasswordHere';\r\nCREATE ROLE<\/pre>\n<p>Now, let&#8217;s add privileges on the created database to the newly created user.<\/p>\n<pre>grant all privileges on database testdb to testuser;<\/pre>\n<p>Now, if you list the databases with the <b>\\l<\/b> command, you will receive the following lines:<\/p>\n<pre>   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges\r\n-----------+----------+----------+-------------+-------------+----------------------\r\n<b>testdb<\/b>| postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc\/postgres         +\r\n          |          |          |             |             | postgres=CTc\/postgres+\r\n          |          |          |             |             | <b>testuser<\/b>=CTc\/postgres\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"6-Connect-to-the-database-with-the-assigned-User\"><\/span>6. Connect to the database with the assigned User<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To connect to a database under a specific user, execute the following command:<\/p>\n<pre>\\c testdb testuser<\/pre>\n<p>Enter the password, and you will receive the following output:<\/p>\n<pre>postgres=# \\c testdb testuser;\r\nPassword for user testuser:\r\nYou are now connected to database \"testdb\" as user \"testuser\".\r\ntestdb=&gt;\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"7-Change-the-Password-of-the-User\"><\/span>7. Change the Password of the User<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To change the password of a user, execute the following command:<\/p>\n<pre>ALTER USER testuser WITH PASSWORD 'NewPasswordHere';<\/pre>\n<p>Once the password is changed, you should receive the following as output:<\/p>\n<pre>postgres=# ALTER USER testuser WITH PASSWORD 'NewPasswordHere';\r\nALTER ROLE\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"8-Reload-PostgreSQL-Configuration\"><\/span>8. Reload PostgreSQL Configuration<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To reload the PostgreSQL configuration without restarting the server execute the following command:<\/p>\n<pre>select pg_reload_conf();<\/pre>\n<p>Once restarted, you will get the following output:<\/p>\n<pre>postgres=# select pg_reload_conf();\r\n pg_reload_conf\r\n----------------\r\n t\r\n(1 row)<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"9-Check-the-PostgreSQL-version\"><\/span>9. Check the PostgreSQL version<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To check the PostgreSQL version via the postgres command line, execute the following command:<\/p>\n<pre>SELECT version();<\/pre>\n<p>You should receive output similar to this:<\/p>\n<pre>postgres=# SELECT version();\r\n                                                             version\r\n---------------------------------------------------------------------------------------------------------------------------------\r\n PostgreSQL 14.5 (Ubuntu 14.5-0ubuntu0.22.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, 64-bit\r\n(1 row)<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"10-Exit-the-PostgreSQL-command-line\"><\/span>10. Exit the PostgreSQL command line<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To exit from the PostgreSQL command line, execute the following command:<\/p>\n<pre>\\q<\/pre>\n<p>That&#8217;s all. We showed you some useful and practical PostgreSQL commands used daily by system administrators, developers, and some regular users. If you find it difficult to manage your PostgreSQL on your own, feel free to contact us anytime you want. We are available 24\/7. All you need to do is to sign up for one of our <a href=\"https:\/\/www.rosehosting.com\">NVMe VPS plans<\/a> and submit a support ticket.<\/p>\n<p>If you liked this post about ten useful and practical PostgreSQL commands, please share it with your friends on social networks or simply leave a reply below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we are going to explain ten useful and practical PostgreSQL commands in Linux. PostgreSQL is a very &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"10 Useful and Practical PostgreSQL Commands\" class=\"read-more button\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#more-43416\" aria-label=\"Read more about 10 Useful and Practical PostgreSQL Commands\">Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":43638,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1702,13,1698],"tags":[103,434],"class_list":["post-43416","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-databases","category-tutorials","category-ubuntu","tag-commands","tag-postgresql","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>10 Useful and Practical PostgreSQL Commands | RoseHosting<\/title>\n<meta name=\"description\" content=\"In this tutorial, we are going to explain ten useful and practical PostgreSQL commands in Linux. Read on to learn more.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"10 Useful and Practical PostgreSQL Commands\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we are going to explain ten useful and practical PostgreSQL commands in Linux. Read on to learn more.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/\" \/>\n<meta property=\"og:site_name\" content=\"RoseHosting\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/RoseHosting\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/rosehosting.helpdesk\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-07T18:30:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-12-28T10:39:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/11\/useful-and-practical-postgresql-commands.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"742\" \/>\n\t<meta property=\"og:image:height\" content=\"372\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Jeff Wilson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"10 Useful and Practical PostgreSQL Commands\" \/>\n<meta name=\"twitter:description\" content=\"In this tutorial, we are going to explain ten useful and practical PostgreSQL commands in Linux. Read on to learn more.\" \/>\n<meta name=\"twitter:creator\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:site\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeff Wilson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/10-useful-and-practical-postgresql-commands\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/10-useful-and-practical-postgresql-commands\\\/\"},\"author\":{\"name\":\"Jeff Wilson\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\"},\"headline\":\"10 Useful and Practical PostgreSQL Commands\",\"datePublished\":\"2022-12-07T18:30:38+00:00\",\"dateModified\":\"2022-12-28T10:39:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/10-useful-and-practical-postgresql-commands\\\/\"},\"wordCount\":636,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/10-useful-and-practical-postgresql-commands\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/useful-and-practical-postgresql-commands.webp\",\"keywords\":[\"Commands\",\"PostgreSQL\"],\"articleSection\":[\"Databases\",\"Tutorials\",\"Ubuntu\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/10-useful-and-practical-postgresql-commands\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/10-useful-and-practical-postgresql-commands\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/10-useful-and-practical-postgresql-commands\\\/\",\"name\":\"10 Useful and Practical PostgreSQL Commands | RoseHosting\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/10-useful-and-practical-postgresql-commands\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/10-useful-and-practical-postgresql-commands\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/useful-and-practical-postgresql-commands.webp\",\"datePublished\":\"2022-12-07T18:30:38+00:00\",\"dateModified\":\"2022-12-28T10:39:28+00:00\",\"description\":\"In this tutorial, we are going to explain ten useful and practical PostgreSQL commands in Linux. Read on to learn more.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/10-useful-and-practical-postgresql-commands\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/10-useful-and-practical-postgresql-commands\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/10-useful-and-practical-postgresql-commands\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/useful-and-practical-postgresql-commands.webp\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/useful-and-practical-postgresql-commands.webp\",\"width\":742,\"height\":372,\"caption\":\"useful and practical postgresql commands\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/10-useful-and-practical-postgresql-commands\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"10 Useful and Practical PostgreSQL Commands\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"name\":\"RoseHosting.com\",\"description\":\"Premium Linux Tutorials Since 2001\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\",\"name\":\"RoseHosting\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"width\":192,\"height\":192,\"caption\":\"RoseHosting\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/RoseHosting\",\"https:\\\/\\\/x.com\\\/rosehosting\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/rosehosting\\\/\"],\"description\":\"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.\",\"email\":\"info@rosehosting.com\",\"telephone\":\"(314) 275-0414\",\"legalName\":\"Rose Web Services LLC\",\"foundingDate\":\"2001-04-02\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"11\",\"maxValue\":\"50\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\",\"name\":\"Jeff Wilson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"caption\":\"Jeff Wilson\"},\"description\":\"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.\",\"sameAs\":[\"https:\\\/\\\/www.rosehosting.com\",\"https:\\\/\\\/www.facebook.com\\\/rosehosting.helpdesk\"],\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/author\\\/jwilson\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"10 Useful and Practical PostgreSQL Commands | RoseHosting","description":"In this tutorial, we are going to explain ten useful and practical PostgreSQL commands in Linux. Read on to learn more.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/","og_locale":"en_US","og_type":"article","og_title":"10 Useful and Practical PostgreSQL Commands","og_description":"In this tutorial, we are going to explain ten useful and practical PostgreSQL commands in Linux. Read on to learn more.","og_url":"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/","og_site_name":"RoseHosting","article_publisher":"https:\/\/www.facebook.com\/RoseHosting","article_author":"https:\/\/www.facebook.com\/rosehosting.helpdesk","article_published_time":"2022-12-07T18:30:38+00:00","article_modified_time":"2022-12-28T10:39:28+00:00","og_image":[{"width":742,"height":372,"url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/11\/useful-and-practical-postgresql-commands.webp","type":"image\/webp"}],"author":"Jeff Wilson","twitter_card":"summary_large_image","twitter_title":"10 Useful and Practical PostgreSQL Commands","twitter_description":"In this tutorial, we are going to explain ten useful and practical PostgreSQL commands in Linux. Read on to learn more.","twitter_creator":"@rosehosting","twitter_site":"@rosehosting","twitter_misc":{"Written by":"Jeff Wilson","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#article","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/"},"author":{"name":"Jeff Wilson","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713"},"headline":"10 Useful and Practical PostgreSQL Commands","datePublished":"2022-12-07T18:30:38+00:00","dateModified":"2022-12-28T10:39:28+00:00","mainEntityOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/"},"wordCount":636,"commentCount":0,"publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/11\/useful-and-practical-postgresql-commands.webp","keywords":["Commands","PostgreSQL"],"articleSection":["Databases","Tutorials","Ubuntu"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/","url":"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/","name":"10 Useful and Practical PostgreSQL Commands | RoseHosting","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#primaryimage"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/11\/useful-and-practical-postgresql-commands.webp","datePublished":"2022-12-07T18:30:38+00:00","dateModified":"2022-12-28T10:39:28+00:00","description":"In this tutorial, we are going to explain ten useful and practical PostgreSQL commands in Linux. Read on to learn more.","breadcrumb":{"@id":"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#primaryimage","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/11\/useful-and-practical-postgresql-commands.webp","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/11\/useful-and-practical-postgresql-commands.webp","width":742,"height":372,"caption":"useful and practical postgresql commands"},{"@type":"BreadcrumbList","@id":"https:\/\/www.rosehosting.com\/blog\/10-useful-and-practical-postgresql-commands\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.rosehosting.com\/blog\/"},{"@type":"ListItem","position":2,"name":"10 Useful and Practical PostgreSQL Commands"}]},{"@type":"WebSite","@id":"https:\/\/www.rosehosting.com\/blog\/#website","url":"https:\/\/www.rosehosting.com\/blog\/","name":"RoseHosting.com","description":"Premium Linux Tutorials Since 2001","publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.rosehosting.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.rosehosting.com\/blog\/#organization","name":"RoseHosting","url":"https:\/\/www.rosehosting.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","width":192,"height":192,"caption":"RoseHosting"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/RoseHosting","https:\/\/x.com\/rosehosting","https:\/\/www.linkedin.com\/in\/rosehosting\/"],"description":"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.","email":"info@rosehosting.com","telephone":"(314) 275-0414","legalName":"Rose Web Services LLC","foundingDate":"2001-04-02","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"11","maxValue":"50"}},{"@type":"Person","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713","name":"Jeff Wilson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","caption":"Jeff Wilson"},"description":"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.","sameAs":["https:\/\/www.rosehosting.com","https:\/\/www.facebook.com\/rosehosting.helpdesk"],"url":"https:\/\/www.rosehosting.com\/blog\/author\/jwilson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/43416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/comments?post=43416"}],"version-history":[{"count":12,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/43416\/revisions"}],"predecessor-version":[{"id":43688,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/43416\/revisions\/43688"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media\/43638"}],"wp:attachment":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media?parent=43416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/categories?post=43416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/tags?post=43416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}