Get the App
SLTechnology News&Howtos  ›  Database  › 

What are the common commands in Postgresql

Shulou Source: shulou.com Published: 2022-05-31 14:52:26 11月12日 Update

This article introduces the knowledge of "what commands are commonly used in Postgresql". In the operation of practical cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

-- setting mode set search_path to firsoul;-- lists only tables in the current mode by default\ dMury-list common modes\ dn-- list all modes\ dnS-- view table size select pg_size_pretty (pg_relation_size ('test')) -- or\ dt+ test--infoSELECT n.nspname as "Schema", c.relname as "Name", CASE c.relkind WHEN 'r' THEN 'table' WHEN' v 'THEN' view' WHEN'm' THEN 'materialized view' WHEN' THEN 'index' WHEN' S' THEN 'sequence' WHEN' s' THEN 'special' WHEN' f 'THEN' foreign table' WHEN 'p'THEN' table' END as "Type", pg_catalog.pg_get_userbyid (c.relowner) as "Owner" Pg_catalog.pg_size_pretty (pg_catalog.pg_table_size (c.oid)) as "Size", pg_catalog.obj_description (c.oid, 'pg_class') as "Description" FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespaceWHERE c.relkind IN '') AND n.nspname! ~'^ pg_toast' AND c.relname OPERATOR (pg_catalog.~)'^ (test) $'AND pg_catalog.pg_table_is_visible (c.oid) ORDER BY 1 spar2 -View schema size, table, index select schemaname, round (sum (pg_total_relation_size (schemaname | |'. | | tablename)) / 1024 from pg_tables where schemaname='public' group by 1024) "Size_MB" from pg_tables where schemaname='public' group by 1 select schemaname, round (sum (pg_total_relation_size (schemaname | |'. | | tablename)) / 1024 lap 1024) "Size_MB" from pg_tables where schemaname='public' group by 1 Select schemaname, round (sum (pg_total_relation_size (schemaname | |'. | indexname) "Size_MB" from pg_indexes where schemaname='public' group by 1-query database size select datname,pg_size_pretty (pg_database_size (datname)) from pg_database; "what are the common commands for Postgresql" here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Patterns commonly used size commands content more knowledge practicality achievement next dilemma reality situation data database article case index ribbon website Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Information MySQL OPPO Reno Microsoft