psql 命令
(1)使用命令行連接數(shù)據庫psql -U postgres -h localhost -p 5433
(2)列出所有的數(shù)據庫\l -- 查看所有數(shù)據庫(3)進入某個數(shù)據庫\c name -- name是表名(4)列出數(shù)據庫的所有數(shù)據表和視圖\d -- 列出所有的數(shù)據表和視圖
\dt
\d tablename 刪除表 drop table (5)列出某個數(shù)據表的所有字段\d table name --table name 是表的名稱 (6)列出視圖的規(guī)則\d+ view name -- view name 視圖的規(guī)則 (7)退出\q --退出下面導出處數(shù)據庫pg_dump -U postgres -h localhost -p 5434 test > testname -- test 需要到出的表名 testname 是導出的文件名 導入已導出的文件(前提要有一個空的數(shù)據庫)刪除整個數(shù)據庫drop database name -- name 數(shù)據庫名創(chuàng)建空數(shù)據庫create database name -- name 是數(shù)據庫名導入psql -U postgres -h localhost -p 5434 test < testname -- test要導入數(shù)據庫的名稱 testname 是之前要導入進來的文件名稱重啟數(shù)據庫服務sudo service postgresql restart// === 清空某個數(shù)據表 ==== truncate table name -- name 是表名 // ==== 重置自增序列 ==== alter sequence name restart with 1 --- name 序列名
\d tablename 刪除表 drop table (5)列出某個數(shù)據表的所有字段\d table name --table name 是表的名稱 (6)列出視圖的規(guī)則\d+ view name -- view name 視圖的規(guī)則 (7)退出\q --退出下面導出處數(shù)據庫pg_dump -U postgres -h localhost -p 5434 test > testname -- test 需要到出的表名 testname 是導出的文件名 導入已導出的文件(前提要有一個空的數(shù)據庫)刪除整個數(shù)據庫drop database name -- name 數(shù)據庫名創(chuàng)建空數(shù)據庫create database name -- name 是數(shù)據庫名導入psql -U postgres -h localhost -p 5434 test < testname -- test要導入數(shù)據庫的名稱 testname 是之前要導入進來的文件名稱重啟數(shù)據庫服務sudo service postgresql restart// === 清空某個數(shù)據表 ==== truncate table name -- name 是表名 // ==== 重置自增序列 ==== alter sequence name restart with 1 --- name 序列名
轉載于:https://www.cnblogs.com/smzd/p/10974883.html
總結
- 上一篇: git checkout 单个文件_In
- 下一篇: NSGA-II算法介绍