Creating a cluster, connecting, and creating a database

Follow this quick walkthrough to configure a Postgres cluster on BigAnimal.

Step 1: Create an account and sign into the portal

If you haven't done so already, you'll need to create your EDB account.

Then, use your newly created account to access the BigAnimal portal.

Step 2: Create a cluster

  1. On the overview page, select Create New Cluster.

    You should now find yourself at the Create Cluster page.

  2. Select the options for your cluster. See Creating a cluster for more information.

Managing your cluster

After you select Create Cluster, you return to the Clusters page with your newly configured cluster now populating the list. From the Clusters page, you can view the details, create a replica of your cluster, and edit and delete your cluster.

Step 3: Connect to your new cluster

  1. Select your cluster to get an overview of how it has been configured. Select the Connect tab to see more information about how to connect to your cluster.

  2. Select the Overview tab and copy the Quick Connect command. Paste it into a terminal where psql is installed. It will prompt for your password and put you on a SQL command line. For example:

    psql -W "postgres://"
    psql (15.2) 
    SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
    Type "help" for help.

While psql is a good all-around option for working with Postgres databases, you can use the client of your choice. See Connect to a cluster for more ideas.

Things to try

Create a new database

We're going to create some sample math data, so we're going to create a database called math. We could use the default edb_admin database, but best practice is to isolate data.

  1. Create a new math database.

    create user math with password 'math_password';
    create database math;
  2. Grant the math role to edb_admin.

    grant math to edb_admin;
  3. Connect to the math database. You're prompted for the edb_admin password you provided in Step 2.

    \connect math

Populate a table and query it

We're going to use temporary tables to calculate prime numbers using a Sieve of Eratosthenes.

  1. Create a table called primes for storing prime numbers.

    CREATE TABLE primes (
      num INTEGER,
      PRIMARY KEY (num)
  2. Populate the table with all prime numbers up to 1000. (This code is based on code from David Fetter.)

    -- Based on
    t0(m) AS (
    t1(n) AS (
        SELECT n+1 FROM t1 WHERE n < (SELECT m FROM t0)
    t2 (n, i) AS (
        SELECT 2*n, 2
        FROM t1 WHERE 2*n <= (SELECT m FROM t0)
            WITH t3(k) AS (
                SELECT max(i) OVER () + 1 FROM t2
            t4(k) AS (
                SELECT DISTINCT k FROM t3
            SELECT k*n, k
            CROSS JOIN
            WHERE k*k <= (SELECT m FROM t0)
    INSERT INTO primes (
      SELECT n FROM t2
      ORDER BY 1
  3. Select the largest prime number less than 1000.

    SELECT max(num)
    FROM primes
    WHERE num < 1000;

Further reading

Now that you've got the basics, see what else BigAnimal offers: