筆記: 環境 - Postgre從安裝到使用

Postgre基本使用

  • 安裝sql

    利用homebrew安裝 brew install postgresql數據庫

  • 啓動post

    利用命令行pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log startui

    注意,postgrel默認啓動端口爲:5432,若是想要修改的話,就在後面加參數-p[port]spa

  • 基本命令命令行

    • 進入環境 psql
    • 切換數據庫 \c databasename
    • 顯示數據表結構 \d tablename
    • 設置自增列 columnname SERIAL
    • 查看當前時區 show time zone
    • 新增表
      create table "xxxx" (
         "id" bigint SERIAL,
        "column1" timestamp without time zone NOT NULL
      );
      複製代碼
    • 查詢 select * from tablename
    • 新增 insert into tablename(column1) values(value1)
    • 刪除 delete from tablename where condition
    • 更新 update tablename set column1 = value1 where condition
    • 格式化表數據 turncate tablename ...
相關文章
相關標籤/搜索