(1)使用命令行連接數據庫psql -U postgres -h localhost -p 5433
(2)列出所有的數據庫\l -- 查看所有數據庫(3)進入某個數據庫\c name -- name是表名(4)列出數據庫的所有數據表和視圖\d -- 列出所有的數據表和視圖
\dt
\d tablename
刪除表
drop table (5)列出某個數據表的所有字段\d table name --table name 是表的名稱
(6)列出視圖的規則\d+ view name -- view name 視圖的規則
(7)退出\q --退出下面導出處數據庫pg_dump -U postgres -h localhost -p 5434 test > testname -- test 需要到出的表名 testname 是導出的文件名
導入已導出的文件(前提要有一個空的數據庫)刪除整個數據庫drop database name -- name 數據庫名創建空數據庫create database name -- name 是數據庫名導入psql -U postgres -h localhost -p 5434 test < testname -- test要導入數據庫的名稱 testname 是之前要導入進來的文件名稱重啟數據庫服務sudo service postgresql restart// === 清空某個數據表 ==== truncate table name -- name 是表名
// ==== 重置自增序列 ==== alter sequence name restart with 1 --- name 序列名