当前位置:网站首页>Preliminary understanding of PostgreSQL (I)

Preliminary understanding of PostgreSQL (I)

2022-06-21 12:36:00 2022 Chongya

Due to the needs of the recent work business , Study PG, By my colleague Amway 《PostgreSQL The way of cultivation The Pragmatic Programmer 》, Extract what you find useful from the book .

It is similar to what I have been exposed to before Oracle Medium sqlplus , A terminal tool
1.psql Tools

\d    View all tables in the current database
\d +  Show more details
\d t  Display the table structure definition
\d tablename_pkey  Show index information
\timing on
 select count(*) from temp;
      Show SQL Executed time
\dn   Show all schema
\db   Show table spaces

Specify the command for character set compilation :
   When the client character set encoding is inconsistent with the server , It will show a jumble ,
   Server side :\encoding gbk;   \encoding utf8
   client : gbk              utf8
 \pset command   Set the output format
 \pset border 0; The output has no border
 \pset border 1; Output content only in content
 \pset border 1; The output has borders inside and outside

\x Split each row of data in the table into single rows
\i  File name    Execute... Stored in an external file SQL file
\echo Used to output a line of information     

psql Using skills
  psql Things in are automatically submitted , Finish one delete perhaps updata sentence , Things are submitted automatically , If you don't want to submit a solution :
  1.begin  ->  dml sentence -> commit/rollback
  2. Use the command line to turn off    \set  AUTOCOMMIT off  (AUTOMINT Must be bigger , Although not wrong , But this does not work )

原网站

版权声明
本文为[2022 Chongya]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206211230058489.html