Reputation: 525
I need to loop through all the table in a database in postgresql. is there a similar stored procedure like mssql sp_msforeachtable for postgresql?
Upvotes: 2
Views: 1389
Reputation: 434665
I usually use this query against information_schema.tables
:
SELECT table_name
FROM information_schema.tables
WHERE table_type = 'BASE TABLE'
AND table_schema = 'public'
ORDER BY table_name
You might want to adjust the table_schema
to suit your needs though. This query should (AFAIK) work in any database that follows the standard.
Upvotes: 3