Thursday, March 17, 2016

SQL: Get the number of rows/records of each table or the total number of rows/records of all tables in Oracle and PostgreSQL? - resolved

A. Get the number of rows of each table.

1. Oracle

      SELECT TABLE_NAME, SUM(NUM_ROWS)
      FROM USER_TABLES
      GROUP BY TABLE_NAME
      ORDER BY TABLE_NAME;

2. PostgreSQL

      SELECT relname, n_live_tup
      FROM pg_stat_user_tables
      WHERE schemaname = '<schema>'
      ORDER BY relname;

B. Get the total number of rows of all tables.

1. Oracle

      SELECT SUM(NUM_ROWS) FROM USER_TABLES;

2. PstgreSQL

      SELECT sum(n_live_tup) FROM pg_stat_user_tables WHERE schemaname = '<schema>';

------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.

No comments:

Post a Comment