Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use the psql command to list, create, use and examine databases?
    primarykey
    data
    text
    <p>I'm a postgreSQL newbie and I can't find any usable introduction to using the psql command. At least I think that's the command I want to use.</p> <p>Is it possible in postgreSQL to simply connect to the server and then list, create, use and examine databases?</p> <p>I'd like to be able to use psql to do something like this with MySQL (I've deleted many extra lines):</p> <p>Connect without specifying a database - I can't seem to do that with psql:</p> <pre><code>$ mysql -u root -prootpassword Welcome to the MySQL monitor. Commands end with ; or \g. Server version: 5.5.28 MySQL Community Server (GPL) </code></pre> <p>I can list databases with mysql but the posgreSQL command SHOW doesn't seem to do it.</p> <pre><code>mysql&gt; show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | ocdp | | performance_schema | | test | +--------------------+ 5 rows in set (0.04 sec) </code></pre> <p>I can switch databases. </p> <pre><code>mysql&gt; use ocdp; Database changed </code></pre> <p>I can't figure out this command in psql:</p> <pre><code>mysql&gt; show tables; +---------------------------------+ | Tables_in_ocdp | +---------------------------------+ | OCAddresses | | OCStreets | +---------------------------------+ 2 rows in set (0.00 sec) </code></pre> <p>I think I can do this in psql with 'createdb' and 'dropdb' commands:</p> <pre><code>mysql&gt; create database foo; Query OK, 1 row affected (0.00 sec) mysql&gt; drop database foo; Query OK, 0 rows affected (0.03 sec) </code></pre> <p>I use \quit</p> <pre><code>mysql&gt; quit Bye </code></pre> <p>The answer to these questions should take only a moment for someone who knows postgreSQL but I just can't find documentation anywhere that shows how to do these simple operations. Maybe I shouldn't even be using psql at all for this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload