DeveloperBreeze

To view tables and the number of records in each table in a PostgreSQL database, you can use the following methods.


Method 1: Using SQL Queries in psql

  1. Connect to PostgreSQL:

Start by connecting to your database using:

   psql -U your_username -d your_database_name
  1. List Tables:

To list all tables in the current schema, use:

   \dt
  1. View Record Counts for Each Table:

Run the following SQL query to see the list of tables along with their row counts:

   SELECT relname AS table_name,
          n_live_tup AS row_count
   FROM pg_stat_user_tables
   ORDER BY table_name;

This query fetches the table names and live row estimates from PostgreSQL’s statistics catalog, pg_stat_user_tables.


Method 2: Using a Database Client (e.g., pgAdmin)

  1. Open pgAdmin and connect to your PostgreSQL server.
  2. Navigate to the Database: In the left sidebar, expand your database and go to Schemas > Tables.
  3. View Table and Row Count:
  • Right-click on each table, select View/Edit Data > All Rows to see the records.
  • Or, run the above SQL query in the Query Tool to see all tables with row counts.

These methods will help you view tables and get a record count for each in your PostgreSQL database.

Continue Reading

Discover more amazing content handpicked just for you

Tutorial

How to Stop SSH From Timing Out

Restart SSH:

sudo systemctl restart sshd

Aug 21, 2025
Read More
Tutorial

🛡️ Protect Your Forms Like a Pro: Anti-Spam Techniques That Actually Work

  • express-rate-limit (Node.js)
  • Laravel's built-in throttling

Check for suspicious content:

Apr 04, 2025
Read More
Tutorial

How to install PostgreSQL

  • Open the psql command line interface from the Start menu or use:
     psql -U postgres

Nov 06, 2024
Read More
Tutorial

How to view tables on a PostgreSQL database hosted on Heroku

   heroku login

Use the following command to connect to your database:

Nov 06, 2024
Read More
Tutorial

How to view your Heroku Apps

Make sure you’re logged in to the Heroku CLI by running:

   heroku login

Nov 06, 2024
Read More
Tutorial

Clearing Unnecessary Logs on Ubuntu

This command will remove journal logs older than 7 days. Adjust the time parameter as needed.

Crash logs are stored in /var/crash/ and are useful for debugging. To view crash logs:

Oct 24, 2024
Read More
Tutorial

Getting Started with DevSecOps — Secure CI/CD Pipelines with Jenkins

SonarQube can be integrated into your Jenkins pipeline to perform static analysis for code quality and security issues.

  • Install SonarQube locally or use a cloud instance.
  • Add SonarQube to your Jenkins pipeline:

Oct 22, 2024
Read More
Tutorial
bash

How to Install and Configure Apache on Ubuntu

To install Apache on your server, use the following command:

sudo apt install apache2

Oct 21, 2024
Read More
Tutorial
bash

How to Create SSL for a Website on Ubuntu

sudo certbot renew --dry-run

If there are no errors, Certbot is successfully configured to automatically renew your certificates before they expire.

Oct 21, 2024
Read More
Tutorial
bash

How to Install MongoDB Shell (mongosh) on Ubuntu

Extract the contents of the downloaded file using the tar command:

tar -xzvf mongosh-1.10.1-linux-x64.tgz

Oct 18, 2024
Read More
Tutorial

How to Install MongoDB on Ubuntu

Now that the GPG key is added, we can configure Ubuntu to pull MongoDB packages from the official MongoDB repository.

Run the following command to add the MongoDB 6.0 repository for Ubuntu 22.04 (Jammy):

Oct 18, 2024
Read More
Cheatsheet

PM2 Cheatsheet

pm2 monit
pm2 flush

Oct 14, 2024
Read More
Tutorial
bash

How to Update Node.js and npm on Ubuntu

Once the repository is added, install Node.js:

sudo apt install -y nodejs

Oct 03, 2024
Read More
Tutorial
bash

How to Grant MySQL Root Privileges for 127.0.0.1

Make sure the port is correct (3306 for default MySQL installations).

  • MySQL treats connections from localhost (via Unix socket) and 127.0.0.1 (via TCP/IP) as distinct connections. By default, the root user may only have privileges for localhost, causing an "Access Denied" error when trying to connect from 127.0.0.1.

Oct 03, 2024
Read More
Tutorial
bash

How to Reset the MySQL Root Password Using DROP USER

This grants the new root user full access to all databases and tables, as well as the ability to grant permissions to other users.

   FLUSH PRIVILEGES;

Oct 03, 2024
Read More
Tutorial
bash

How to Use OpenVPN on Ubuntu

Now that your configuration file is in place, you can start and stop the VPN connection.

To start the OpenVPN connection, use the following command:

Sep 15, 2024
Read More
Tutorial
bash

Recovering Your Linux System with GRUB Rescue Commands

grub rescue> linux /vmlinuz root=/dev/sda1 ro
grub rescue> initrd /initrd.img
grub rescue> boot

This sequence manually loads the Linux kernel and initial RAM disk, allowing you to boot into your system.

Sep 01, 2024
Read More
Tutorial
bash

How to Generate and Use SSH Keys with ssh-keygen

Example:

Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_github

Host server.example.com
    HostName server.example.com
    User your_username
    IdentityFile ~/.ssh/id_rsa_example

Aug 29, 2024
Read More
Tutorial

How to Install an AppImage on Linux

  • The ./ tells the terminal to execute the file in the current directory.

Some AppImages offer the option to integrate with your desktop environment, meaning they can add menu entries, icons, and MIME type associations.

Aug 21, 2024
Read More
Tutorial

Adding a Subdomain on an Apache Server

Now that the directory is set up, you need to configure Apache to serve content from that directory when the subdomain is accessed.

   sudo nano /etc/apache2/sites-available/blog.example.com.conf

Aug 21, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!