=========================================
--DB size
select
pg_database_size('databaseName');
/*
?column? | pg_database_size
----------+------------------
48104 | 7840623
*/
postgres=# \l+
/*
List of databases
Name
| Owner | Encoding | Collate
| Ctype |
Access privileges | Size
| Tablespace |
Description
----------------+---------------+----------+-------------+-------------+-----------------------+---------+------------+--------------------------------------------
MyDB_Name | MyDB_Name user | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 47 MB | pg_default |
MyDB_Name tmpdb | MyDB_Name tmp | UTF8
| en_US.UTF-8 | en_US.UTF-8 | | 17 MB | pg_default |
*/
=========================================
--Connect a DB
\c DBNAME
/*
postgres=# \c MyDB_Name
You are now
connected to database "MyDB_Name " as user "postgres".
MyDB_Name =#
*/
\connect
DBNAME
/*
MyDB_Name =#
\connect postgres
You are now
connected to database "postgres" as user "postgres".
postgres=#
*/
=========================================
--Show tables
1.
\? list all the commands
2.
\l list databases
3.
\conninfo display information about current connection
4.
\c [DBNAME] connect to new database, e.g., \c template1
5.
\dt list tables of the public schema
6.
\dt <schema-name>.* list tables of certain schema, e.g., \dt public.*
7.
\dt *.* list tables of all schemas
No comments:
Post a Comment
If you have any doubt or question, please contact us.