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