postgresql for mac简单操作

frankslgdeMacBook-Pro:~ frankslg$ pg_ctl -D /usr/local/var/postgres/ -l /usr/local/var/postgres/server.log stop
waiting for server to shut down………….. done
server stopped
在关闭的时候一定要注意,如果有服务正在使用postgresql时,stop会关闭失败

frankslgdeMacBook-Pro:~ frankslg$ pg_ctl -D /usr/local/var/postgres/ -l /usr/local/var/postgres/server.log start
server starting

启动成功之后,需要连接数据库(连接之前先查看有哪些库)
frankslg$ psql -l
然后进入:

frankslgdeMacBook-Pro:~ frankslg$ psql msf
psql (9.4.5)
Type "help" for help.

msf=# 

使用命令(方法)查看:

msf=# \?
General
  \copyright             show PostgreSQL usage and distribution terms
  \g [FILE] or ;         execute query (and send results to file or |pipe)
  \gset [PREFIX]         execute query and store results in psql variables
  \h [NAME]              help on syntax of SQL commands, * for all commands
  \q                     quit psql
  \watch [SEC]           execute query every SEC seconds

Query Buffer
  \e [FILE] [LINE]       edit the query buffer (or file) with external editor
  \ef [FUNCNAME [LINE]]  edit function definition with external editor
  \p                     show the contents of the query buffer
  \r                     reset (clear) the query buffer
  \s [FILE]              display history or save it to file
  \w FILE                write query buffer to file

Input/Output
  \copy ...              perform SQL COPY with data stream to the client host
  \echo [STRING]         write string to standard output
  \i FILE                execute commands from file
  \ir FILE               as \i, but relative to location of current script
  \o [FILE]              send all query results to file or |pipe
  \qecho [STRING]        write string to query output stream (see \o)
:   #此后还有很多命令

使用“\dt”查看当前库中有哪些表

msf=# \dt
                            List of relations
 Schema |                      Name                      | Type  | Owner 
--------+------------------------------------------------+-------+-------
 public | api_keys                                       | table | msf
 public | automatic_exploitation_match_results           | table | msf
 public | automatic_exploitation_match_sets              | table | msf
 public | automatic_exploitation_matches                 | table | msf
 public | automatic_exploitation_runs                    | table | msf
 public | clients                                        | table | msf
 public | credential_cores_tasks                         | table | msf
 public | credential_logins_tasks                        | table | msf
 public | creds                                          | table | msf
 public | events                                         | table | msf

之后就和其它数据库的操作一样了:

msf=# select * from api_keys;
 id | token | created_at | updated_at 
----+-------+------------+------------
(0 rows)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值