Friday, March 4, 2016

postgresql: list / get all sequences, functions, tables, views, and indexes

A. SEQUENCE

          SELECT * FROM information_schema.sequences WHERE sequence_schema = '<schema>';

          SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = '<schema>';

B. FUNCTION

          SELECT routine_name FROM information_schema.routines WHERE routine_schema = '<schema>';

          SELECT r.routine_name || '(' || p.data_type || ')' FROM information_schema.routines r INNER JOIN information_schema.parameters p ON r.specific_name = p.specific_name WHERE r.specific_schema ='<schema>';

To get a function by its name:

      select pg_get_functiondef(oid) from pg_proc where proname = '<your function name>';

C. TABLE

         SELECT TABLENAME FROM pg_tables WHERE SCHEMANAME = '<schema>';

          SELECT table_name FROM information_schema.tables WHERE table_schema='<schema>';

D. VIEW

         SELECT viewname FROM pg_views WHERE schemaname='<schema>';

          SELECT table_name FROM information_schema.views WHERE table_schema='<schema>';

E. INDEX

SELECT relname FROM pg_class, pg_index WHERE pg_class.oid = pg_index.indexrelid AND relname !~ '^pg_';

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

                        
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